PHPackages                             tr33m4n/di - 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. tr33m4n/di

ActiveLibrary

tr33m4n/di
==========

A basic DI container

v1.1.0(4y ago)09MITPHPPHP ^7.3CI failing

Since Apr 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/tr33m4n/di)[ Packagist](https://packagist.org/packages/tr33m4n/di)[ RSS](/packages/tr33m4n-di/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (6)Versions (12)Used By (0)

di
==

[](#di)

A very simple DI container and auto-wiring implementation

Basic Usage
-----------

[](#basic-usage)

### Configuration

[](#configuration)

Creating and getting classes using the container can be done without any configuration, however configuring the container will allow for class preferences to be set as well as class parameters. For example:

```
return [
    Container\GetPreference::CONFIG_KEY => [
        \Some\Interface\To\Implement::class => \Some\Class\To\Bind::class
    ],
    Container\GetParameters::CONFIG_KEY => [
        \Some\Class\To\Bind::class => [
            'testParam' => 'something',
            'anotherClass' => \Some\Class\Argument::class
        ],
        \Some\Class\Argument::class => [
            'anotherTestParam' => 'somethingElse'
        ]
    ]
];
```

### `get`

[](#get)

The simplest usage is without providing any configuration. All constructor arguments of class `\Some\Class\To\Get` when called with `get` will be auto-wired:

```
