PHPackages                             gres/dim - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gres/dim

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gres/dim
========

The PHP dependency injection manager

1.0.0(12y ago)419MITPHPPHP &gt;=5.3.0

Since Apr 21Pushed 12y ago1 watchersCompare

[ Source](https://github.com/GR3S/Dim)[ Packagist](https://packagist.org/packages/gres/dim)[ RSS](/packages/gres-dim/feed)WikiDiscussions master Synced 3d ago

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

Dim – PHP Dependency Injection Manager
======================================

[](#dim--php-dependency-injection-manager)

[![Build Status](https://camo.githubusercontent.com/144fa4575b4e8d190cbf855928e5e2b28c7ac13dc5262ffae916727734cd68c0/68747470733a2f2f7472617669732d63692e6f72672f475233532f44696d2e737667)](https://travis-ci.org/GR3S/Dim)[![Coverage Status](https://camo.githubusercontent.com/6cae523619ed33b4d338c1fe8054f5eb76b7113602ef53c3f3f2bc0756309f14/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f475233532f44696d2f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/GR3S/Dim?branch=master)[![Latest Version](https://camo.githubusercontent.com/1fc83c3b38a949e3f7950d6330bb5ec3fe480b20663643818f4b6355f029a68b/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f475233532f44696d2e737667)](https://github.com/GR3S/Dim/releases)[![License](https://camo.githubusercontent.com/4dc30f12ecc40b59040d464ec91b20a779c1704e6ad33fa3c5a244fffa42d29e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f677265732f64696d2e737667)](https://github.com/GR3S/Dim/blob/master/LICENSE)

Dim is a small, simple and powerful Dependency Injection Container for PHP:

```
use Dim\Container;
use Dim\Service;

class One { /* ... */ }

class Two { /* ... */ }

class Foo
{
    public function __construct(One $one, Two $two, $three)
    {
        // ...
    }
    // ...
}

// Instantiates the container
$container = new Container;
// Puts service that creates an instance of "One" to the container
$container->set(new Service('One'));
// Puts instance of "Two" to the container
$container->set(new Two);
// Puts service that creates an instance of "Foo" to the container
$container->set(new Service('Foo'));
// ...
// Instantiates "Foo" passing dependencies "One", "Two" and third argument "3" to the constructor
$three = $container->get('Foo', array('three' => 3));
```

Dim works with PHP 5.3 or later.

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

[](#installation)

You may install the Dim with [Composer](https://getcomposer.org).

1. Create a `composer.json` file in your project root and run the `php composer.phar install` command to install it:

    ```
    {
        "require": {
            "gres/dim": "1.*"
        }
    }
    ```
2. Add this line to your application’s index.php file:

    ```
