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

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

php-strict/container
====================

Interface and implementation of common container.

v1.0.0(7y ago)0961GPL-2.0-or-laterPHPPHP ^7.1

Since May 6Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (1)

Container
=========

[](#container)

[![Software License](https://camo.githubusercontent.com/e1514dd3f2095dbf68a0008ae62a631142953ad2e86aa94c504343f2c2c191da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c2d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/546784e8ca9890aa2d12f60325b049d313414fa247832a7a8dd1a76e0e1e3f19/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7068702d7374726963742f636f6e7461696e65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/php-strict/container)[![codecov](https://camo.githubusercontent.com/384325b533906a4bc89a4d7210a4c3275a8f7349270c80db75c85eec39016ecc/68747470733a2f2f636f6465636f762e696f2f67682f7068702d7374726963742f636f6e7461696e65722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/php-strict/container)[![Codacy Badge](https://camo.githubusercontent.com/2b2246a34def662f3b31dcf7d8dca21cd6612cccd507fcf4571f280f3c65cd4d/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3035646137653131306535353436356261653064353464613638633466326431)](https://www.codacy.com/app/php-strict/container?utm_source=github.com&utm_medium=referral&utm_content=php-strict/container&utm_campaign=Badge_Grade)

Interface and implementation of common container.

Strict version of [PSR-11](https://www.php-fig.org/psr/psr-11/)with additional methods to set/get references (instead of values) and get all container entries as array.

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

[](#requirements)

- PHP &gt;= 7.1

Install
-------

[](#install)

Install with [Composer](http://getcomposer.org):

```
composer require php-strict/container
```

Usage
-----

[](#usage)

Classic usage:

```
use PhpStrict\Container\Container

$container = new Container();
$container->set('key1', 1);

if ($container->has('key1')) {
    $var1 = $container->get('key1');
}
```

Usage to set/get references:

```
use PhpStrict\Container\Container

$myObject = new stdClass();

$container = new Container();
$container->setByRef('key2', $myObject);

$anotherObject =& $container->getRef('key2');
```

Set container values through constructor:

```
use PhpStrict\Container\Container

$container = new Container([
    'key1' => 1,
    'key2' => 'value 2',
    'key3' => true,
]);

if ($container->has('key2')) {
    $var2 = $container->get('key2');
}
```

Unpacking container through callback:

```
use PhpStrict\Container\Container

class MyClass
{
    protected $field1;
    protected $field2;
    protected $field3;

    public function unpacker(array $entries): void
    {
        foreach ($entries as $key => $value) {
            $this->$key = $value;
        }
    }
}

$container = new Container([
    'field1' => 1,
    'field2' => 'value 2',
    'field3' => true,
]);

$myClassObject = new MyClass();

$container->unpackWith([$myClassObject, 'unpacker']);
```

Tests
-----

[](#tests)

To execute the test suite, you'll need [Codeception](https://codeception.com/).

```
vendor\bin\codecept run
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2566d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f404fa292f952ba0429cfe11f608e982e0d9d645f2ac864c53abee7f71dff2b?d=identicon)[enikeishik](/maintainers/enikeishik)

---

Top Contributors

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

---

Tags

containerphpphp-libraryphp7phpcontainerstrict

###  Code Quality

TestsCodeception

### Embed Badge

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

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

###  Alternatives

[gacela-project/container

A minimalistic container dependency resolver

1175.2k2](/packages/gacela-project-container)

PHPackages © 2026

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