Forked from symfony/dependency-injection

[READ-ONLY] Subtree split of the Symfony DependencyInjection Component -- clone into Symfony/Component/ (master at symfony/symfony)

License: MIT

Language: PHP

DependencyInjection Component

DependencyInjection manages your services via a robust and flexible Dependency Injection Container.

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

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

$sc = new ContainerBuilder();
    ->register('foo', '%foo.class%')
    ->addArgument(new Reference('bar'))
$sc->setParameter('foo.class', 'Foo');


Method Calls (Setter Injection):

$sc = new ContainerBuilder();

    ->register('bar', '%bar.class%')
    ->addMethodCall('setFoo', array(new Reference('foo')))
$sc->setParameter('bar.class', 'Bar');


Factory Class:

If your service is retrieved by calling a static method:

$sc = new ContainerBuilder();

    ->register('bar', '%bar.class%')
$sc->setParameter('bar.class', 'Bar');


File Include:

For some services, especially those that are difficult or impossible to autoload, you may need the container to include a file before instantiating your class.

$sc = new ContainerBuilder();

    ->register('bar', '%bar.class%')
$sc->setParameter('bar.class', 'Bar');



You can run the unit tests with the following command:


If you also want to run the unit tests that depend on other Symfony Components, install dev dependencies before running PHPUnit:

php composer.phar install --dev

Project Statistics

Sourcerank 0
Repository Size 754 KB
Stars 3
Forks 1
Watchers 27
Open issues disabled
Dependencies 3
Contributors 47
Tags 8
Last updated
Last pushed

Top Contributors See all

Fabien Potencier Johannes Christophe Coevoet Jeremy Mikola Jordi Boggiano Kris Wallsmith Pascal Borreli Victor Berchet Lukas Kahwe Smith Ryan Weaver Bulat Shakirzyanov Martin Hasoň Igor Hugo Hamon William Durand Noel GUILBERT Joseph Bielawski Jan Prieser Miha Vrhovnik Henrik Westphal

Recent Tags See all

v2.0.10 February 06, 2012
v2.0.9 January 06, 2012
v2.0.7 December 09, 2011
v2.0.6 November 17, 2011
v2.0.5 November 02, 2011
v2.0.4 October 04, 2011
v2.0.1 August 26, 2011
v2.0.0 July 28, 2011

Something wrong with this page? Make a suggestion

Login to resync this repository