PHPackages                             phpbench/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpbench/container

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

phpbench/container
==================

Simple, configurable, service container.

2.2.3(9mo ago)1515.3M↓10.9%6[1 PRs](https://github.com/phpbench/container/pulls)4MITPHPCI failing

Since Jun 29Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/phpbench/container)[ Packagist](https://packagist.org/packages/phpbench/container)[ RSS](/packages/phpbench-container/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (5)Versions (14)Used By (4)

PHPBench Service Container
==========================

[](#phpbench-service-container)

[![Build Status](https://camo.githubusercontent.com/8765582290646d3868a18cea4a02823fb84b9f98d620a8dab9b19e2b894c0262/68747470733a2f2f7472617669732d63692e6f72672f70687062656e63682f636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpbench/container)

Simple, extensible dependency injection container with parameters and service tagging. Implements [container interop](https://github.com/container-interop/container-interop).

Simple usage
------------

[](#simple-usage)

```
$container = new Container();
$container->register('foobar', function (Container $container) {
    return new \stdClass();
});
```

Extending and Tagging
---------------------

[](#extending-and-tagging)

Extension classes should be passed as the first argument to the container (the user configuration is the second argumnet).

```
$container = new Container(
    [
        MyExtension::class
    ],
    [
        'foo.bar' => 'my_new_value',
    ]
);
$container->init(); // will trigger loading of the extensions.
```

```
class MyExtension implements ExtensionInterface
{
    public function load(Container $container)
    {
        $container->register('my_service', function (Container $container) {
            $service = new MyService(
                $container->getParameter('foo_bar'),
                $container->get('some_other_service')
            );

            foreach ($container->getServiceIdsForTag('tag') as $serviceId => $params) {
                $service->add($container->get($serviceId));
            }

            return $service;
        });

        $container->register('tagged_service', function (Container $container) {
            return new MyService(
                $container->getParameter('foo_bar'),
                $container->get('some_other_service')
            );
        }, [ 'tag' => [ 'param1' => 'foobar' ]);
    }

    /**
     * Return the default parameters for the container.
     *
     * @return array
     */
    public function getDefaultConfig()
    {
        return [
            'foo_bar' => 'this is foo'
        ];
    }
}
```

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance57

Moderate activity, may be stable

Popularity57

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 73.3% 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 ~333 days

Recently: every ~419 days

Total

11

Last Release

285d ago

Major Versions

1.2.1 → 2.0.02020-10-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/24ec7d5d6b7ea54007be5d7b4f43800381cc1e22929f7d2276fba30e497fdfa6?d=identicon)[dantleech](/maintainers/dantleech)

---

Top Contributors

[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (22 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (2 commits)")[![Kocal](https://avatars.githubusercontent.com/u/2103975?v=4)](https://github.com/Kocal "Kocal (1 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (1 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (1 commits)")[![racastellanosm](https://avatars.githubusercontent.com/u/6352390?v=4)](https://github.com/racastellanosm "racastellanosm (1 commits)")[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (1 commits)")[![keulinho](https://avatars.githubusercontent.com/u/15930605?v=4)](https://github.com/keulinho "keulinho (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k464.3M10.6k](/packages/symfony-dependency-injection)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k257.0M28.0k](/packages/friendsofphp-php-cs-fixer)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k17.0M1.1k](/packages/phpro-grumphp)[illuminate/contracts

The Illuminate Contracts package.

707133.3M15.2k](/packages/illuminate-contracts)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[illuminate/container

The Illuminate Container package.

31083.8M2.5k](/packages/illuminate-container)

PHPackages © 2026

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