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(6mo ago)1512.9M↓12.2%6[1 PRs](https://github.com/phpbench/container/pulls)4MITPHPCI failing

Since Jun 29Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/phpbench/container)[ Packagist](https://packagist.org/packages/phpbench/container)[ RSS](/packages/phpbench-container/feed)WikiDiscussions master Synced 1mo 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

58

—

FairBetter than 98% of packages

Maintenance67

Regular maintenance activity

Popularity56

Moderate usage in the ecosystem

Community25

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

193d 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

[illuminate/container

The Illuminate Container package.

31178.1M2.0k](/packages/illuminate-container)[symfony/rate-limiter

Provides a Token Bucket implementation to rate limit input and output in your application

27047.2M147](/packages/symfony-rate-limiter)[symfony/ldap

Provides a LDAP client for PHP on top of PHP's ldap extension

1407.5M46](/packages/symfony-ldap)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[symfony/object-mapper

Provides a way to map an object to another object

34885.7k18](/packages/symfony-object-mapper)

PHPackages © 2026

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