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

ActiveLibrary

runner/container
================

container for runner framework

v1.0.3(6y ago)194MITPHPPHP &gt;=7.1CI failing

Since Apr 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/RunnerLee/container)[ Packagist](https://packagist.org/packages/runner/container)[ RSS](/packages/runner-container/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Runner IoC Container
====================

[](#runner-ioc-container)

A small IoC Container for PHP

[![](https://camo.githubusercontent.com/af462e6b45620f7cd37038acb13fce24d1a429ba7dc2936d664ce82d17f1808a/68747470733a2f2f7472617669732d63692e6f72672f52756e6e65724c65652f636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/RunnerLee/container)[![](https://camo.githubusercontent.com/c48f3a8fc34963f6eada0aa6369ab5fff674f7e8d2020354de9a734b5f879bf9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e6e65724c65652f636f6e7461696e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572 "Scrutinizer Code Coverage")](https://scrutinizer-ci.com/g/RunnerLee/container/?branch=master)[![](https://camo.githubusercontent.com/4d9fc4e1369c703685bc894e02468fd5416e5beb401b24b338d339ec70bcf49d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e6e65724c65652f636f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572 "Scrutinizer Code Quality")](https://scrutinizer-ci.com/g/RunnerLee/container/?branch=master)[![StyleCI](https://camo.githubusercontent.com/3427fad94da16d9758267b16cec20180b8d14da6b51ed36662fdd80f18d0c0bc/68747470733a2f2f7374796c6563692e696f2f7265706f732f3137363139393736312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/176199761)[![](https://camo.githubusercontent.com/71438af321ad2f8db84062187c90608d5034bf13c18dc34bd73d8151dfcf8d92/68747470733a2f2f706f7365722e707567782e6f72672f72756e6e65722f636f6e7461696e65722f762f737461626c65)](https://github.com/RunnerLee/container)[![](https://camo.githubusercontent.com/21223b9ffedc1feec4026ec59947bafeec1e45b69a0e2fd1383975636e8d09a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e302d3838393242462e737667)](http://www.php.net/)[![](https://camo.githubusercontent.com/59a9fb3d293c9f28bdf61c9432b6ac535812cdff488e76d737a711a23d7ba44e/68747470733a2f2f706f7365722e707567782e6f72672f72756e6e65722f636f6e7461696e65722f6c6963656e7365)](https://github.com/RunnerLee/container)

### Installation

[](#installation)

```
$ composer require runner/container

```

### Usage

[](#usage)

create an instance of the container, and bind services into the container with a name.

#### basic binding

[](#basic-binding)

```
use Runner\Container\Container;

$container = new Container();

$container->bind('stack', SplStack::class);

$container->make('stack');

$container->bind(ArrayAccess::class, function () {
    return new ArrayObject();
});
```

#### binding implementation

[](#binding-implementation)

use an interface name as name and bind a concrete implementation to it

```
$container->bind(ArrayAccess::class, function () {
    return new ArrayObject();
});

$container->make(ArrayAccess::class);
```

#### binding singleton

[](#binding-singleton)

```
$container->bind(
    'db',
    function () {
        return new PDO();
    },
    true
);

$container->bind();
```

#### binding instance

[](#binding-instance)

just another way to binding singleton

```
$pdo = new PDO();

$container->instance('db', $pdo);
```

#### alias binding

[](#alias-binding)

bind an alias as concrete to a registered service

```
$container->bind(CacheInterface::class, function () {
    return new FileCache();
});

$container->bind('cache', CacheInterface::class, true);

$container->make('cache');
```

have fun :)

#### contextual binding

[](#contextual-binding)

bind different implementation to classes while doing injecting

```
$container->bind(CacheInterface::class, function () {
    return new FileCache();
});

$container->bind('redis_cache', function () {
    return new RedisCache();
});

$container->bindContext(
    PageController::class,
    CacheInterface::class,
    function (Container $container) {
        return $container->make('redis_cache');
    }
);

$controller = $container->make(PageController::class);
```

### References

[](#references)

- [Laravel Container](https://laravel.com/docs/5.8/container)
- [Pimple](https://pimple.symfony.com/)
- [依赖注入与Ioc容器](https://blog.csdn.net/dream_successor/article/details/79078905)
- [\[Wikipedia\] inversion of control](https://en.wikipedia.org/wiki/Inversion_of_control)

### License

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

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

Total

3

Last Release

2190d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15872de2a16678788e3008d3874fbffe0b136088bca5ae96974189a357f99222?d=identicon)[RunnerLee](/maintainers/RunnerLee)

---

Top Contributors

[![RunnerLee](https://avatars.githubusercontent.com/u/7436388?v=4)](https://github.com/RunnerLee "RunnerLee (41 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[api-platform/state

API Platform state interfaces

223.4M57](/packages/api-platform-state)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[symfony/json-streamer

Provides powerful methods to read/write data structures from/into JSON streams.

14440.0k8](/packages/symfony-json-streamer)[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

632.3k](/packages/rubix-server)

PHPackages © 2026

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