Simple and lightweight Dependency Injection Container
This library provides a simple and lightweight Dependency Injection Container.
Interfaces: Extended container interfaces compatible with container-interop
Classes: Advanced and feature-complete container implementations based on the interfaces
To make use of the API, include the vendor autoloader and use the classes:
namespace Acme\MyApplication; use FlameCore\Container\EditableContainer; $container = new EditableContainer();
define() items to require a value type. To assign values to items, use the
$container->define('bar', 'Acme\MyApplication\Config'); // or 'Config::class' $container->set('bar', new Config()); $container->has('bar'); $container->get('bar');
This works also with arrays and scalar types:
$container->define('foo', ':string'); $container->set('foo', 'bar');
Install Composer if you don't already have it present on your system:
$ curl -sS https://getcomposer.org/installer | php
To install the library, run the following command and you will get the latest version:
$ composer require flamecore/container
- You must have at least PHP version 5.4 installed on your system.
If you want to contribute, please see the CONTRIBUTING file first.
Thanks to the contributors:
- Christian Neff (secondtruth)