PHPackages                             itlessons/php-ioc - 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. itlessons/php-ioc

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

itlessons/php-ioc
=================

PHP Inversion of Control(IoC) Library

0.0.1(11y ago)1331941MITPHPPHP &gt;=5.4.0

Since Feb 27Pushed 11y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

PHP Inversion of Control(IoC) Library
=====================================

[](#php-inversion-of-controlioc-library)

Very simple tool for managing class dependencies. Dependency injection is a method of removing hard-coded class dependencies. Instead, the dependencies are injected at run-time, allowing for greater flexibility as dependency implementations may be swapped easily.

Here is a simple example that shows how to register services and parameters:

```
use IoC\Container;

$c = new Container();

$c->setParameter('cache', array(
    'host' => '127.0.0.1',
    'port' => 11211,
));

$c->singleton('cache', function (Container $c) {
    $cache = new Memcached();
    $cache->addServer(
        $c->getParameter('cache.host'),
        $c->getParameter('cache.port')
    );
    return $cache;
});

// single instance of Memcached
$value = $c->make('cache');

```

Resolving a class dependencies:

```
use IoC\Container;

$c = new Container();
$c->singleton('cache', 'MemcachedCache');

class MemcachedCache extends Cache
{
    public function __construct(Memcached $cache)
    {
        $this->cache = $cache;
    }
}

$cache = $c->make('cache');

```

Resolving a simple class:

```
use IoC\Container;

$c = new Container();

class FooBar
{
    public function __construct(Container $c, Baz $baz)
    {
        $this->container = $c;
        $this->baz = $baz;
    }
}

$fooBar = $c->make('FooBar');

```

Binding an interface to an implementation:

```
use IoC\Container;

$c = new Container();
$c->bind('UserRepositoryInterface', 'DbUserRepository');

class UserController extends BaseController {

    public function __construct(UserRepositoryInterface $users)
    {
        $this->users = $users;
    }

}

$c->make('UserController');

```

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

[](#installation)

The recommended way to install php-ioc is through [Composer](http://getcomposer.org). Just create a `composer.json` file and run the `php composer.phar install` command to install it:

```
{
    "require": {
        "itlessons/php-ioc": "*"
    }
}

```

Alternatively, you can download the [php-ioc.zip](https://github.com/itlessons/php-ioc/archive/master.zip) file and extract it.

Resources
---------

[](#resources)

You can run the unit tests with the following command:

```
$ cd path/to/php-ioc/
$ composer.phar install
$ phpunit

```

Links
-----

[](#links)

\[Принцип Inversion of Control (IoC) в вашем php проекте\] ()

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

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

4098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7283c22f1b152268a8a17acd947f00c4f65f41401a34407f2319de57cca45fb8?d=identicon)[itlessons](/maintainers/itlessons)

---

Top Contributors

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

---

Tags

containerdependencyioc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/itlessons-php-ioc/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A fast and intuitive dependency injection container.

86787.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)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)

PHPackages © 2026

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