Julio Montoya 321ce65f18 Updating vendors 11 жил өмнө
..
Compiler 321ce65f18 Updating vendors 11 жил өмнө
Dumper 321ce65f18 Updating vendors 11 жил өмнө
Exception d7041815fc Updating vendors 11 жил өмнө
Extension c36303a24b Updating vendors 11 жил өмнө
LazyProxy 321ce65f18 Updating vendors 11 жил өмнө
Loader d7041815fc Updating vendors 11 жил өмнө
ParameterBag d7041815fc Updating vendors 11 жил өмнө
Tests 321ce65f18 Updating vendors 11 жил өмнө
Alias.php 32682a9ca8 Updating vendor 12 жил өмнө
CHANGELOG.md 1ad9119c46 Updating vendors + adding doctrine bridge, and forms 12 жил өмнө
Container.php 321ce65f18 Updating vendors 11 жил өмнө
ContainerAware.php 32682a9ca8 Updating vendor 12 жил өмнө
ContainerAwareInterface.php 06eb0a00e6 Updating vendors 12 жил өмнө
ContainerBuilder.php 3dd9d88e31 Updating vendors 11 жил өмнө
ContainerInterface.php 32682a9ca8 Updating vendor 12 жил өмнө
Definition.php d7041815fc Updating vendors 11 жил өмнө
DefinitionDecorator.php 321ce65f18 Updating vendors 11 жил өмнө
IntrospectableContainerInterface.php 32682a9ca8 Updating vendor 12 жил өмнө
LICENSE 32682a9ca8 Updating vendor 12 жил өмнө
Parameter.php 32682a9ca8 Updating vendor 12 жил өмнө
README.md 32682a9ca8 Updating vendor 12 жил өмнө
Reference.php 32682a9ca8 Updating vendor 12 жил өмнө
Scope.php 32682a9ca8 Updating vendor 12 жил өмнө
ScopeInterface.php 32682a9ca8 Updating vendor 12 жил өмнө
SimpleXMLElement.php 32682a9ca8 Updating vendor 12 жил өмнө
TaggedContainerInterface.php 32682a9ca8 Updating vendor 12 жил өмнө
Variable.php 32682a9ca8 Updating vendor 12 жил өмнө
composer.json 224a0e666e Updating vendors 11 жил өмнө
phpunit.xml.dist 32682a9ca8 Updating vendor 12 жил өмнө

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:

$ cd path/to/Symfony/Component/DependencyInjection/
$ composer.phar install --dev
$ phpunit