PHPackages                             celemas/container - 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. celemas/container

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

celemas/container
=================

A PSR-11 compatible dependency injection library

0.4.0(4w ago)034MITPHPPHP ^8.5CI passing

Since Jan 30Pushed 3w agoCompare

[ Source](https://github.com/celemas/container)[ Packagist](https://packagist.org/packages/celemas/container)[ Docs](https://celemas.dev/container)[ RSS](/packages/celemas-container/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Celemas Container
=================

[](#celemas-container)

[![ci](https://github.com/celemas/container/actions/workflows/ci.yml/badge.svg)](https://github.com/celemas/container/actions)[![codecov](https://camo.githubusercontent.com/25d7e0be58791e0f359dcef91dd7dfd8fd34a20e26025d6e0490f48ea8cb3cdd/68747470733a2f2f636f6465636f762e696f2f6769746875622f63656c656d61732f636f6e7461696e65722f67726170682f62616467652e7376673f746f6b656e3d324b4e514f4234504e44)](https://codecov.io/github/celemas/container)[![psalm coverage](https://camo.githubusercontent.com/b2975ebc355195a05abb2c21c8a1770245b48a191686f44817248d22690eba57/68747470733a2f2f73686570686572642e6465762f6769746875622f63656c656d61732f636f6e7461696e65722f636f7665726167652e7376673f)](https://shepherd.dev/github/celemas/container)[![psalm level](https://camo.githubusercontent.com/a265fedd0f112aec62852eae922d26814ac6c3c932a810e1aa756a7cf14d20a6/68747470733a2f2f73686570686572642e6465762f6769746875622f63656c656d61732f636f6e7461696e65722f6c6576656c2e7376673f)](https://shepherd.dev/github/celemas/container)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)

A PSR-11 compatible dependency injection container.

Entry lifetimes
---------------

[](#entry-lifetimes)

Container entries use explicit lifetimes:

- `shared()` caches one instance per container (default for added entries)
- `scoped()` caches one instance per requesting container scope
- `transient()` never caches
- `value()` returns the configured definition as-is (for literals or raw closures)

```
$container->add('config', ['debug' => true])->value();
$container->add(Service::class)->shared();
$container->add(RequestContext::class)->scoped();
$container->add(Builder::class)->transient();
```

Scope mode
----------

[](#scope-mode)

Use `scope()` to create an isolated container for one unit of work:

```
$root = new Container();
$root->add('app-name', 'celemas')->value();
$root->add('global-service', GlobalService::class)->shared();
$root->add('request-service', RequestService::class)->scoped();

$scope = $root->scope();
$scope->add(Request::class, $request)->value();

// ... resolve request-local services
$scope->reset();
```

After the first `scope()` call, the root container is sealed and no longer accepts structural mutations. Scope tags can inherit pre-defined root tags while keeping their own local caches.

Services that should be cleaned between scopes can implement `Celemas\Container\Resettable` and will be reset during `$scope->reset()`.

License
-------

[](#license)

This project is licensed under the [MIT license](LICENSE.md).

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance95

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Total

4

Last Release

28d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c15f1690b643e5cbf205fd28f3b2ebb6c7448d34774bb92b7952150c901a689?d=identicon)[ernstla](/maintainers/ernstla)

---

Top Contributors

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

---

Tags

containerPSR-11dependency-injectiondiiocpsr11

### Embed Badge

![Health badge](/badges/celemas-container/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k53.2M1.2k](/packages/php-di-php-di)[slince/di

A flexible dependency injection container

20268.4k6](/packages/slince-di)

PHPackages © 2026

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