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

ActiveLibrary

atekushi/singleton
==================

Small Library to Implement Singleton Pattern To Your Project

1.0.0(1y ago)0131MITPHPPHP ^8.0

Since Jan 14Pushed 1y agoCompare

[ Source](https://github.com/atekushi/singleton)[ Packagist](https://packagist.org/packages/atekushi/singleton)[ RSS](/packages/atekushi-singleton/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (1)

What is Singleton?
------------------

[](#what-is-singleton)

The Singleton pattern is a design pattern that restricts the instantiation of a class to a single instance. It is commonly used to represent shared resources, such as configuration settings, logging services, or database connections.

---

Why Use it ?
------------

[](#why-use-it-)

- Ensures only one instance of a class is created.
- Supports lazy initialization (instance is created only when needed).
- Simple and easy-to-use API.
- Provides a utility method to check if a class follows the Singleton pattern.

---

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

[](#installation)

Install the library via Composer:

```
  composer require atekushi/singleton
```

Usage
-----

[](#usage)

Just extend the singleton class to your target class

```
include 'vendor/autoload.php';

use Atekushi\Singleton\Singleton;

class Config extends Singleton
{
    private array $settings;

    protected function __construct(array $settings = [])
    {
        $this->settings = $settings;
    }

    public function get(string $key, $default = null)
    {
        return $this->settings[$key] ?? $default;
    }
}

// Usage
$config = Config::getInstance(['app_name' => 'MyApp', 'debug' => true]);
echo $config->get('app_name');
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance41

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

489d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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