kekrozsak/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection
Polonkai Gergely 9d0d2ce524 Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
..
Compiler Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Dumper Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Exception Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
Extension Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Loader Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
ParameterBag Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Tests Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
.gitignore Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Alias.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
CHANGELOG.md Upgraded to Symfony 2.1-beta2 2012-07-15 14:56:31 +02:00
Container.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
ContainerAware.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
ContainerAwareInterface.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
ContainerBuilder.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
ContainerInterface.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Definition.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
DefinitionDecorator.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
IntrospectableContainerInterface.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
LICENSE Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
Parameter.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
README.md Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
Reference.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
Scope.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
ScopeInterface.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
SimpleXMLElement.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
TaggedContainerInterface.php Updated to Symfony 2.1 BETA3 2012-07-16 21:40:19 +02:00
Variable.php Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
composer.json Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00
phpunit.xml.dist Initial commit with Symfony 2.1+Vendors 2012-07-01 09:52:20 +02:00

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