PHPackages                             web6/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. web6/singleton

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

web6/singleton
==============

PHP Singleton design pattern

0.0.1(6y ago)048GPL-3.0-or-laterPHP

Since May 19Pushed 5y agoCompare

[ Source](https://github.com/w6cloud/php-singleton-trait)[ Packagist](https://packagist.org/packages/web6/singleton)[ RSS](/packages/web6-singleton/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

WEB6 PHP Singleton Trait
========================

[](#web6-php-singleton-trait)

Implementation of singleton design pattern in PHP5.4+ using a trait.

Install
-------

[](#install)

Install via Composer

```
$ composer require web6/singleton
```

Usage
-----

[](#usage)

### Configure autoload

[](#configure-autoload)

Configure autoloading by including Composer's generated file :

```
include_once('vendor/autoload.php');
```

### Create a singleton class

[](#create-a-singleton-class)

To create a singleton class simply use the `W6\Sinfleton\SingletonTrait` and move the `__construct()` logic to the `init()` method.

```
class App {

    use \W6\Singleton\SingletonTrait;

    public $message = 'Not inited';

    protected function init() {
        $this->message = 'Inited';
    }
}
```

### Use your class

[](#use-your-class)

Anywhere in your application you can request the same instance of the class.

```
$app = App::instance();
echo $app->message;
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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

Unknown

Total

1

Last Release

2551d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e97dd2e75248779e468eb3dea9b83ebe935d7effa3ccf00286ed3bae43fac9f9?d=identicon)[w6](/maintainers/w6)

---

Top Contributors

[![13i](https://avatars.githubusercontent.com/u/1174353?v=4)](https://github.com/13i "13i (2 commits)")[![w6cloud](https://avatars.githubusercontent.com/u/32245185?v=4)](https://github.com/w6cloud "w6cloud (1 commits)")

### Embed Badge

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

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

###  Alternatives

[cagartner/correios-consulta

Package para pesquisa de serviços de busca por cep, calculo de frete e etc, diretamente nos serviços dos Correios.

159301.8k](/packages/cagartner-correios-consulta)

PHPackages © 2026

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