PHPackages                             thesmart/singleton - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. thesmart/singleton

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

thesmart/singleton
==================

A simple Singleton pattern, with optional support for named instances.

v0.0.2(13y ago)21332MITPHPPHP &gt;=5.3.0

Since Jul 27Pushed 13y agoCompare

[ Source](https://github.com/thesmart/php-singleton)[ Packagist](https://packagist.org/packages/thesmart/singleton)[ Docs](https://github.com/thesmart/php-singleton)[ RSS](/packages/thesmart-singleton/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (2)

Singleton PHP Library by John Smart ([@thesmart](https://github.com/thesmart))
==============================================================================

[](#singleton-php-library-by-john-smart-thesmart)

A simple Singleton pattern, with optional support for named instances.

Example:

```
MyClass::setInstance(new MyClass());
$myClass = Singleton::getInstance();
$has = SingletonMock::hasInstance();

```

Named instances:

```
SingletonMock::setInstance($myClass, 'foobar');
$myClass = Singleton::getInstance('foobar');
$has = SingletonMock::hasInstance('foobar');

```

Like this project?
==================

[](#like-this-project)

Check out my others. [@thesmart](https://twitter.com/thesmart)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

5040d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11f682ea6d98e41ccb56db0a284ac5b085fd31d40c3119cf8c3e493f87498c0a?d=identicon)[thesmart](/maintainers/thesmart)

---

Top Contributors

[![thesmart](https://avatars.githubusercontent.com/u/280877?v=4)](https://github.com/thesmart "thesmart (2 commits)")

---

Tags

patternsingletonglobalsinstances

### Embed Badge

![Health badge](/badges/thesmart-singleton/health.svg)

```
[![Health](https://phpackages.com/badges/thesmart-singleton/health.svg)](https://phpackages.com/packages/thesmart-singleton)
```

###  Alternatives

[league/pipeline

A plug and play pipeline implementation.

1.0k16.0M74](/packages/league-pipeline)[florianwolters/component-util-singleton

The Singleton (and Registry of Singletons a.k.a. Multiton) design pattern as a PHP component.

13175.8k5](/packages/florianwolters-component-util-singleton)[getsolaris/laravel-make-service

A MVCS pattern create a service command for Laravel 5+

81161.3k](/packages/getsolaris-laravel-make-service)[redeyeventures/geopattern

Generate beautiful SVG patterns.

11140.8k2](/packages/redeyeventures-geopattern)[functional-php/pattern-matching

Pattern matching for PHP with automatic destructuring.

8261.5k](/packages/functional-php-pattern-matching)[php-stubs/wordpress-globals

Global variables and global constants from WordPress core.

13799.0k17](/packages/php-stubs-wordpress-globals)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
