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

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

php-packages/container
======================

An IoC container for PHP: simple, fast, clean.

1.2.0(11y ago)04781MITPHP

Since Feb 2Pushed 11y agoCompare

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

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

Container [![Build Status](https://camo.githubusercontent.com/d530f5106be44be7d9ced9722806bf655ad5617053999a4ff4fc5a143532c125/68747470733a2f2f7472617669732d63692e6f72672f7068702d7061636b616765732f636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-packages/container)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#container-)

An IoC container for PHP: simple, fast, clean.

### Features

[](#features)

- injecting via type-hinting
- injecting via property annotations
- manual dependencies injecting via an array

Navigation
----------

[](#navigation)

- [Installation](#installation)
- [Usage](#usage)
- [Development](#development)
- [Additional information](#additional-information)

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

[](#installation)

```
composer require php-packages/container
```

Usage
-----

[](#usage)

### mixed make(string|mixed $class, array $dependencies = \[\])

[](#mixed-makestringmixed-class-array-dependencies--)

```
class A
{
}

get_class(container()->make("A")); # => "A"
get_class(container()->make(new A)); # => "A"

class B
{

    public function __construct(array $foo = [], A $bar)
    {
        var_dump($foo); # => []
        get_class($bar); # => "A"
    }
}

container()->make("B");

class C
{

    public function __construct(array $foo)
    {
        var_dump($foo); # => [1, 2, "C"]
    }
}

container()->make("C", [[1, 2, raw("C")]]);
```

### object inject(object $instance)

[](#object-injectobject-instance)

The `inject` method be always called inside of `make`.

```
class C
{
}

class A
{

    /**
     * @shouldBeInjected
     * @var C
     */
    public $b;
}

get_class(container()->inject(new A)->b); # => "C"
```

### void bind(string $binding, string|object $value)

[](#void-bindstring-binding-stringobject-value)

```
container()->bind("foo", "stdClass");
container()->bind("bar", $bar = new stdClass);

var_dump(container()->make("foo")); # => an instance of stdClass
var_dump(container()->make("bar") === container()->make("bar")); # => true
```

Development
-----------

[](#development)

```
make run-tests
make coverage-report coverage-report-server
```

Additional information
----------------------

[](#additional-information)

*Container* is released under the MIT license.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

4106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/270a6b451bb75c99beae25836d16453daf58531cfac6baecd8d0a72059baa44b?d=identicon)[bound1ess](/maintainers/bound1ess)

---

Top Contributors

[![bound1ess](https://avatars.githubusercontent.com/u/10074992?v=4)](https://github.com/bound1ess "bound1ess (58 commits)")

---

Tags

containerdependency-injectioniocinversion of control

### Embed Badge

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

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)[slince/di

A flexible dependency injection container

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

A small PHP 5.3 dependency injection container extended from Laravel container.

334.9k2](/packages/godruoyi-easy-container)

PHPackages © 2026

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