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

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

piotrpress/singleton
====================

This library is a Singleton (anti)pattern implementation using a Traits with a support for an Object Inheritance and passing parameters to the constructor.

v7.0.0(1y ago)01774GPL-3.0PHPPHP &gt;=7.4

Since Nov 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PiotrPress/singleton)[ Packagist](https://packagist.org/packages/piotrpress/singleton)[ Docs](https://github.com/PiotrPress/singleton)[ RSS](/packages/piotrpress-singleton/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (9)Used By (4)

Singleton
=========

[](#singleton)

This library is a [Singleton](https://en.wikipedia.org/wiki/Singleton_pattern) (anti)pattern implementation using a [Traits](https://www.php.net/manual/en/language.oop5.traits.php) with a support for an [Object Inheritance](https://www.php.net/manual/en/language.oop5.inheritance.php) and passing parameters to the constructor.

Installation
------------

[](#installation)

```
composer require piotrpress/singleton
```

Usage
-----

[](#usage)

```
require __DIR__ . '/vendor/autoload.php';

use PiotrPress\Singleton;

class ExampleParent {
    use Singleton;
}

class Example extends ExampleParent {
    protected function __construct( $arg ) {}
}

Example::getInstance( 'arg' );
```

Requirements
------------

[](#requirements)

PHP &gt;= `7.4` version.

License
-------

[](#license)

[GPL3.0](license.txt)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

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 ~148 days

Recently: every ~259 days

Total

8

Last Release

609d ago

Major Versions

v2.0.0 → v3.0.02021-11-13

v3.0.0 → v4.0.02021-11-13

v4.0.0 → v5.0.02021-11-13

v5.0.0 → v6.0.02021-11-13

v6.0.1 → v7.0.02024-09-15

PHP version history (2 changes)v1.0.0PHP ^7.4

v6.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10326736?v=4)[Piotr Niewiadomski](/maintainers/PiotrPress)[@PiotrPress](https://github.com/PiotrPress)

---

Top Contributors

[![PiotrPress](https://avatars.githubusercontent.com/u/10326736?v=4)](https://github.com/PiotrPress "PiotrPress (8 commits)")

---

Tags

antipatterninheritanceobject-inheritancepatternsingletonsingleton-patternsingletonpatternsingletonstraittraitstraitpatterntraitssingletoninheritanceantipatternobject inheritance

### Embed Badge

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

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

###  Alternatives

[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89152.7M321](/packages/nette-robot-loader)[league/pipeline

A plug and play pipeline implementation.

1.0k16.0M74](/packages/league-pipeline)[kkszymanowski/traitor

Add a trait use statement to existing PHP class

1305.2M16](/packages/kkszymanowski-traitor)[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)[rikbruil/specification

A PHP implementation of the Specification-pattern

18284.8k1](/packages/rikbruil-specification)

PHPackages © 2026

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