PHPackages                             pokmot/pimple-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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. pokmot/pimple-singleton

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

pokmot/pimple-singleton
=======================

Extending Pimple to be a singleton

3.0.0(10y ago)45.5kMITPHP

Since Sep 16Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

Pimple Container as a Singleton
===============================

[](#pimple-container-as-a-singleton)

The task is simple: I'd like to easily get my Pimple Container from anywhere in the code.

Whether it's a module, an external class, independent library that has no idea which framework my particular project is using, or, I'd like not to worry about how I am passing it around.

So a singleton seems the easy option.

The singleton is created automatically when the Container is invoked. You can do this:

```
new \PimpleSingleton\Container();
$di = \PimpleSingleton\Container::getContainer();
```

Have you already defined your Pimple instance, for instance through a framework initialization, or maybe in a unit test?

```
$di = new Pimple\Container();
\PimpleSingleton\Container::setContainer($di);
$di = \PimpleSingleton\Container::getContainer();
```

Using PhpStorm (the greatest IDE of them all... ;-)

```
namespace PHPSTORM_META {
  /** @noinspection PhpUnusedLocalVariableInspection */
  /** @noinspection PhpIllegalArrayKeyTypeInspection */
  $STATIC_METHOD_TYPES = [
      \PimpleSingleton\Container::get('') => array(
          'db' instanceof \Aura\Sql\ExtendedPdo,
          'request' instanceof \Slim\Http\Request,
          'response' instanceof \Slim\Http\Response
      )
  ];
}

```

PhpStorm will now perform autocompletion for code like this:

```
$db = \PimpleSingleton\Container::get('db');

```

Enjoy!

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

3897d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3821243b901a4d314cfefd7838eb735e2556047731529f96abc1a86b0a700704?d=identicon)[pokmot](/maintainers/pokmot)

---

Top Contributors

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

---

Tags

containerdependency-injectionpimple

### Embed Badge

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

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)

PHPackages © 2026

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