Sevajol Bastien 042ee0f750 uppgrade to dev version (2013-02-18) and add admin generator bundl 11 years ago
..
Compiler uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Dumper uppgrade to dev version (2013-02-18) and add admin generator bundl 11 years ago
Exception uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Extension uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Loader uppgrade to 2.1.7 and fix code for upgrade 11 years ago
ParameterBag uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Tests uppgrade to dev version (2013-02-18) and add admin generator bundl 11 years ago
.gitignore uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Alias.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
CHANGELOG.md uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Container.php uppgrade to dev version (2013-02-18) and add admin generator bundl 11 years ago
ContainerAware.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
ContainerAwareInterface.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
ContainerBuilder.php uppgrade to dev version (2013-02-18) and add admin generator bundl 11 years ago
ContainerInterface.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Definition.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
DefinitionDecorator.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
IntrospectableContainerInterface.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Parameter.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
README.md uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Reference.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Scope.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
ScopeInterface.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
SimpleXMLElement.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
TaggedContainerInterface.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
Variable.php uppgrade to 2.1.7 and fix code for upgrade 11 years ago
composer.json uppgrade to 2.1.7 and fix code for upgrade 11 years ago
phpunit.xml.dist uppgrade to 2.1.7 and fix code for upgrade 11 years ago

README.md

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();
$sc
    ->register('foo', '%foo.class%')
    ->addArgument(new Reference('bar'))
;
$sc->setParameter('foo.class', 'Foo');

$sc->get('foo');

Method Calls (Setter Injection):

$sc = new ContainerBuilder();

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

$sc->get('bar');

Factory Class:

If your service is retrieved by calling a static method:

$sc = new ContainerBuilder();

$sc
    ->register('bar', '%bar.class%')
    ->setFactoryClass('%bar.class%')
    ->setFactoryMethod('getInstance')
    ->addArgument('Aarrg!!!')
;
$sc->setParameter('bar.class', 'Bar');

$sc->get('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();

$sc
    ->register('bar', '%bar.class%')
    ->setFile('/path/to/file')
    ->addArgument('Aarrg!!!')
;
$sc->setParameter('bar.class', 'Bar');

$sc->get('bar');

Resources

You can run the unit tests with the following command:

phpunit

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