Download the PHP package fastero/php-di without Composer
On this page you can find all versions of the php package fastero/php-di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fastero/php-di
More information about fastero/php-di
Files in fastero/php-di
Package php-di
Short Description Simple and fast php dependency injector
License MIT
Homepage https://github.com/lehaBay/php-di
Informations about the package php-di
PHP Dependency Injector
Simple and fast Dependency Injector. It supports autowire and autoloading.
requires php 7.0 +
Easy to install with composer
Usage
As simple as this, no configuration needed just proper typehins for the constructor.
Of course by very definition of dependency injector you don't usually call $di->get() often, only in a very core of the application and then let all the dependencies to be injected.
More complete examples: let's create some classes to work with
No configuration needed by default, but if you must here is how to use utility class ServiceConfiguration to add some configuration:
Using ServiceConfiguration is recommended way of creating configuration for services even though actual configuration is a simple array and can be created manually but this utility class helps to avoid mistakes. Using this class does not create bunch of objects so it has almost no overhead. Downside is that one have to call ->get() at the very end of each definition
So creating configuration must be started with one of the ->setup*(..) methods and finished with ->get() method which actually returns configuration array
result:
MIT Licensed, http://www.opensource.org/licenses/MIT