Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
[READ-ONLY] Subtree split of the Symfony DependencyInjection Component -- clone into Symfony/Component/ (master at symfony/symfony)
PHP

Merge branch '2.8'

* 2.8: (21 commits)
  Fix merge
  Fix typo
  Various fixes esp. on Windows
  Fix the validation of form resources to register the default theme
  Fix the retrieval of the value with property path when using a loader
  [appveyor] minor enhancements
  [Process] Disable failing tests on Windows
  [Translation] Fix the string casting in the XliffFileLoader
  Windows and Intl fixes
  Add appveyor.yml for C.I. on Windows
  [VarDumper] fixed HtmlDumper to target specific the head tag
  [travis] merge php: nightly and deps=high test-matrix lines
  consistently use str_replace to unify directory separators
  Support omitting the <target> node in an .xlf file.
  Fix the handling of values for multiple choice types
  moved PHP nightly to PHP 7.0
  fixed tests using deprecation features
  [Form] made deprecation notice more precise
  fixed CS
  Fix BC break after split of ACL from core
  ...

Conflicts:
	.travis.yml
	composer.json
	src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
	src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php
	src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php
	src/Symfony/Component/Locale/Tests/LocaleTest.php
Failed to load latest commit information.
Compiler Unpack nested array instead of using temp var
Dumper Merge branch '2.8'
Exception [DependencyInjection] fixed ? position in some exception messages (re…
Extension [2.3] CS And DocBlock Fixes
LazyProxy made {@inheritdoc} annotations consistent across the board
Loader Unpack nested array instead of using temp var
ParameterBag Merge branch '2.8'
Tests Merge branch '2.8'
.gitignore Added missing files .gitignore
Alias.php Docblock fixes
CHANGELOG.md Added a way to define the priority of service decoration
Container.php [DependencyInjection] Add initialized() to the ContainerInterface
ContainerAware.php [DependencyInjection] made ContainerAware class abstract.
ContainerAwareInterface.php [FramworkBundle] fix phpdoc of commands
ContainerAwareTrait.php Remove executable bit on PHP file
ContainerBuilder.php Merge branch '2.8'
ContainerInterface.php [DependencyInjection] Add initialized() to the ContainerInterface
Definition.php Merge branch '2.8'
DefinitionDecorator.php Merge branch '2.8'
ExpressionLanguage.php Fixed minor typo - override
ExpressionLanguageProvider.php [DependencyInjection] added support for custom expression language fu…
IntrospectableContainerInterface.php [DependencyInjection] Add initialized() to the ContainerInterface
LICENSE Updated copyright to 2015
Parameter.php [DependencyInjection] tagged the public @api
README.md Merge branch '2.3' into 2.6
Reference.php Add "shared" flag and deprecate scopes concept
ResettableContainerInterface.php Implement resettable containers
Scope.php Add "shared" flag and deprecate scopes concept
ScopeInterface.php Add "shared" flag and deprecate scopes concept
TaggedContainerInterface.php fixed CS
Variable.php [2.3] CS And DocBlock Fixes
composer.json Merge branch '2.8'
phpunit.xml.dist [PhpUnitBridge] new bridge for testing with PHPUnit

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%')
    ->setFactory(array('%bar.class%', '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 install
$ phpunit
Something went wrong with that request. Please try again.