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

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

pollen-solutions/container
==========================

Pollen Solutions - Container Component - PSR-11 ready Dependencies Injection Container.

v1.0.7(3y ago)05211MITPHPPHP ^7.4 || ^8.0

Since Jul 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/pollen-solutions/container)[ Packagist](https://packagist.org/packages/pollen-solutions/container)[ Docs](https://www.presstify.com/pollen-solutions/container/)[ RSS](/packages/pollen-solutions-container/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (4)Versions (10)Used By (1)

Container Component
===================

[](#container-component)

[![Latest Stable Version](https://camo.githubusercontent.com/4b8a01cac8cab66af772676f0dc42d4825e899dee5beca34882bd0efb1b0b6f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6c6c656e2d736f6c7574696f6e732f636f6e7461696e65722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/pollen-solutions/container)[![MIT Licensed](https://camo.githubusercontent.com/daa52099573be5a50c320c4387496400f2f722e49f86a42db8d5778130d3582d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](LICENSE.md)[![PHP Supported Versions](https://camo.githubusercontent.com/d9d71d0b69072c51e1ff7adfdb6270f896f75787500ce6437120e23727c081d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d3838393242463f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net/supported-versions.php)

Pollen Solutions **Container** Component is a PSR-11 ready Dependencies Injection Container.

Installation
------------

[](#installation)

```
composer require pollen-solutions/container
```

Basic Usage
-----------

[](#basic-usage)

```
use Pollen\Container\Container;

$container = new Container();

class Foo {
    public $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }
}

class Bar {}

$container->add(Foo::class, function () use ($container){
    return new Foo($container->get(Bar::class));
});
$container->add(Bar::class);

$foo = $container->get(Foo::class);

var_dump($foo instanceof Foo);
var_dump($foo->bar instanceof Bar);
```

Service Providers
-----------------

[](#service-providers)

```
use Pollen\Container\Container;
use Pollen\Container\ServiceProvider;

// Classes definitions
class Foo {
    public $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }
}

class Bar {}

// Service Provider definition
class FooBarServiceProvider extends ServiceProvider
{
    protected $provides = [
        Foo::class,
        Bar::class
    ];

    public function register(): void
    {
        $this->getContainer()->add(Foo::class, function () {
            return new Foo($this->getContainer()->get(Bar::class));
        });

        $this->getContainer()->add(Bar::class);
    }
}

// Service Provider declaration
$container = new Container();

$container->addServiceProvider(new FooBarServiceProvider());

$foo = $container->get(Foo::class);

// Test
var_dump($foo instanceof Foo);
var_dump($foo->bar instanceof Bar);
```

### Bootable Service Providers

[](#bootable-service-providers)

```
// Classes definitions
class Foo {
    public $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }

    public function onBoot(): void
    {
        var_dump(sprintf('%s booted through Service Provider!', __CLASS__));
    }
}

class Bar {}

// Service Provider definition
class FooBarServiceProvider extends BootableServiceProvider
{
    protected $provides = [
        Foo::class,
        Bar::class
    ];

    public function boot(): void
    {
        /** @var Foo::class $foo */
        $foo = $this->getContainer()->get(Foo::class);
        $foo->onBoot();
    }

    public function register(): void
    {
        $this->getContainer()->add(Foo::class, function () {
            return new Foo($this->getContainer()->get(Bar::class));
        });

        $this->getContainer()->add(Bar::class);
    }
}

// Service Provider declaration
$container = new Container();
$serviceProviders = [];

$container->addServiceProvider($serviceProviders[] = new FooBarServiceProvider());

// Boot all Bootable service providers
foreach ($serviceProviders as $serviceProvider) {
    if ($serviceProvider instanceof BootableServiceProviderInterface) {
        $serviceProvider->boot();
    }
}
exit;
```

Delegate Containers
-------------------

[](#delegate-containers)

```
use Pollen\Container\Container;

$mainContainer = new Container();
$delegateContainer = new Container();

$mainContainer->delegate($delegateContainer);

class Foo {
    public $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }
}

class Bar {}

$mainContainer->add(Foo::class, function () use ($mainContainer){
    return new Foo($mainContainer->get(Bar::class));
});

$delegateContainer->add(Bar::class);

$foo = $mainContainer->get(Foo::class);

var_dump($foo instanceof Foo);
var_dump($foo->bar instanceof Bar);
```

Auto Wiring
-----------

[](#auto-wiring)

```
use Pollen\Container\Container;

interface FooInterface {}
class Foo implements FooInterface {
    public $bar;

    public function __construct(BarInterface $bar)
    {
        $this->bar = $bar;
    }
}

interface BarInterface {}
class Bar implements BarInterface {}

$container = new Container();
$container->enableAutoWiring();

$container->add(FooInterface::class, Foo::class);
$container->add(BarInterface::class, Bar::class);

$foo = $container->get(Foo::class);

var_dump($foo instanceof Foo);
var_dump($foo->bar instanceof Bar);
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

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

Every ~55 days

Recently: every ~46 days

Total

9

Last Release

1334d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1d9488545d6b446f8df86ec373a070e7fed1166fc47e1324d963e46d3d838d3?d=identicon)[presstify](/maintainers/presstify)

---

Top Contributors

[![jordy-manner](https://avatars.githubusercontent.com/u/733356?v=4)](https://github.com/jordy-manner "jordy-manner (16 commits)")

---

Tags

containerdependency-injectionphpcontainerPSR-11componentpollen-solutions

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[chubbyphp/chubbyphp-container

A simple PSR-11 container implementation.

1978.4k14](/packages/chubbyphp-chubbyphp-container)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)[selective/container

A simple PSR-11 container implementation with autowiring.

1220.4k4](/packages/selective-container)[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

124.2k3](/packages/devanych-di-container)

PHPackages © 2026

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