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

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

flotzilla/container
===================

PHP FIG PSR-11 container implementation

2.2.2(6y ago)431[2 PRs](https://github.com/flotzilla/container/pulls)MITPHPPHP ^7.1CI failing

Since Mar 2Pushed 6y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (3)Versions (12)Used By (0)

[![MIT License](https://camo.githubusercontent.com/da09026611ef483db9af4349dc98d050ee6f8e605c33d138256270d696009122/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/flotzilla/container/blob/master/LICENCE.md)

Container
=========

[](#container)

Dependency injection PHP FIG PSR-11 container implementation

Requirements
------------

[](#requirements)

`php > 7.1`

Install
-------

[](#install)

via Composer

```
$ composer require flotzilla/container
```

Usage
-----

[](#usage)

Init service container with constructor parameters

```
 $container = new \flotzilla\Container\Container(
     [
         'EmptyTestClassDI' => EmptyTestClass::class, // class without dependencies, init by classname
         'TestClassDI' => [TestClass::class, 'message'], // class with constructor string parameter
         'TestClassDI2' => function () { // closure, that returns new class instance
             return new TestClass('test');
         },
        'ClosureDI' => function ($x, $y) { // closure, that returns sum result
             return $x + $y;
         },

         'TestClassWithDependecyDI' => [TestClassWithDependecy::class, 'TestClassDI'] // class with dependency of another service
     ]
 );
```

Or with setter

```
use \flotzilla\Container\Container;
$container = new Container();

$container->set('LoggerDI', function () { return new Logger();});
$container->set('ClosureDI', function ($x, $y) { return $x + $y;});
$container->set('EmptyTestClassDI', ClassWithoutConstructor::class);
$container->set('ClassDIWithDependency', [SomeClass::class, 'message']);
$container->set('AnotherClassWithDIDependency', [TestClass::class, 'LoggerDI']);
```

Get your component in code

```
$logger = $container->get('LoggerDI');
```

Get your closure with arguments

```
$container->set('ClosureDI', function ($x, $y) { return $x + $y;});
$logger = $container->getWithParameters('ClosureDI', [1, 2]); // will return 3
```

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/flotzilla/container/blob/master/LICENCE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Total

10

Last Release

2259d ago

Major Versions

1.2.0 → 2.0.0.x-dev2020-03-04

### Community

Maintainers

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

---

Top Contributors

[![0bbyte](https://avatars.githubusercontent.com/u/3332506?v=4)](https://github.com/0bbyte "0bbyte (28 commits)")

---

Tags

containerdependency-injectionphppsr-11psr-11-compliantcontainerdependencyinjectiondiserviceprovider

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)[miladrahimi/phpcontainer

Dependency injection (IoC) container for PHP projects

1322.7k2](/packages/miladrahimi-phpcontainer)

PHPackages © 2026

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