PHPackages                             buzzingpixel/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. [Framework](/categories/framework)
4. /
5. buzzingpixel/container

ActiveLibrary[Framework](/categories/framework)

buzzingpixel/container
======================

A dependency injection container for PHP

1.1.1(3y ago)04731Apache-2.0PHPPHP ^7.4|^8.0

Since Dec 26Pushed 3y agoCompare

[ Source](https://github.com/buzzingpixel/container)[ Packagist](https://packagist.org/packages/buzzingpixel/container)[ RSS](/packages/buzzingpixel-container/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (9)Versions (4)Used By (1)

BuzzingPixel ContainerInterface implementation
==============================================

[](#buzzingpixel-containerinterface-implementation)

A simple, concrete, easy to configure implementation of the PSR ContainerInterface. This container will auto-wire whatever it can. You can also provide bindings directly.

Configuring bindings
--------------------

[](#configuring-bindings)

Bindings are configured by an array in the Container's constructor.

The keys in this array should be the classnames you wish to provide bindings for.

The values can be:

### An object

[](#an-object)

If an object is provided, it will be treated as the concrete implementation for the classname.

### A string

[](#a-string)

If a string is provided as the value, it will be treated as an ID for another entry in the container and will recurse back to the `get` method to get the specified item. This is most useful for binding interfaces to concrete implementations.

### A callable

[](#a-callable)

If a callable is provided, it will be called the first time the entry is requested and is expected to provide the concrete implementation. It receives as its only argument the container instance.

Example:

```
$container = new \BuzzingPixel\Container\Container(
    bindings: [
        // You'd probably never do this exactly like this, but you get the idea
        SomeClass::class => new SomeClass(),

        // Bind a concrete implementation to an interface
        SomeInterface::class => SomeImplementation::class,

        // A factory method to create the requested class
        AnotherClass::class => function (\Psr\Container\ContainerInterface $container): AnotherClass {
            return new AnotherClass(
                apiKey: env('API_KEY'),
                someDependency: $container->get(SomeDependency::class),
            );
        }
    ],
);
```

Configuring constructor params
------------------------------

[](#configuring-constructor-params)

Sometimes, you want to let auto-wiring do its thing, but you need to configure just one parameter on some class — say, maybe an API key string. That's why the container constructor has `array $constructorParamConfigs` as an argument. The array should be instances of `\BuzzingPixel\Container\ConstructorParamConfig`.

Through the `ConstructorParamConfig` constructor, you provide the name of the class to be configured (`$id`), the name of the param to configure, and the value to give.

Example:

```
$container = new \BuzzingPixel\Container\Container(
    constructorParamConfigs: [
        new \BuzzingPixel\Container\ConstructorParamConfig(
            id: SomeClassToConfigure::class,
            param: 'apiKey', // or whatever the name of the param is
            give: 'fooBarApiKey',
        ),
        new \BuzzingPixel\Container\ConstructorParamConfig(
            id: AnotherClassToConfigure::class,
            param: 'someInterface',
            give: SomeConcreteImplementation::class,
        ),
    ],
);
```

Caching
-------

[](#caching)

The container is pretty efficient, and for many applications, you may not need caching. However, if you're looking to eek out a little more performance in production, you can provide a cache implementation as the third argument in the constructor of the container. You *could* write your own, or you can use the file cache implementation bundled with this package.

The cache is invoked for any auto-wired class so that after it's been auto-wired, a factory is written to the cache file and loaded into the bindings of the container on next request so that reflection is not used for this class on future requests.

Example:

```
$container = new \BuzzingPixel\Container\Container(
    cacheAdapter: new \BuzzingPixel\Container\Cache\FileCache\FileCache(
        cacheFileHandler: new \BuzzingPixel\Container\Cache\FileCache\CacheFileHandler(
            cacheDirectoryPath: '/path/to/desired/cache/directory',
        ),
    ),
);
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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

Total

3

Last Release

1198d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27433694?v=4)[BuzzingPixel, LLC](/maintainers/buzzingpixel)[@buzzingpixel](https://github.com/buzzingpixel)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[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)

PHPackages © 2026

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