Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Merge branch '2.4'

* 2.4:
  unified return null usages
  [Validator] added Japanese translation
  Textarea value should default to empty string instead of null.
  Fix doc blocks
  [Process] Fix #10681, process are failing on Windows Server 2003
  updated doc
  [Security] fix DBAL connection typehint
  [HttpFoundation] status 201 is allowed to have a body
  unified return null usages

Conflicts:
	src/Symfony/Component/DependencyInjection/ContainerBuilder.php
	src/Symfony/Component/DomCrawler/Crawler.php
	src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php
latest commit 84ed369a35
Fabien Potencier fabpot authored April 18, 2014
Octocat-spinner-32 Compiler Merge branch '2.4' April 18, 2014
Octocat-spinner-32 Dumper Merge branch '2.4' April 16, 2014
Octocat-spinner-32 Exception [DependencyInjection] fixed ? position in some exception messages (re… May 01, 2013
Octocat-spinner-32 Extension minor #10717 unified return null usages (fabpot) April 18, 2014
Octocat-spinner-32 LazyProxy made {@inheritdoc} annotations consistent across the board April 16, 2014
Octocat-spinner-32 Loader Merge branch '2.4' April 16, 2014
Octocat-spinner-32 ParameterBag Merge branch '2.3' into 2.4 April 16, 2014
Octocat-spinner-32 Tests Merge branch '2.4' April 18, 2014
Octocat-spinner-32 .gitignore Added missing files .gitignore July 21, 2013
Octocat-spinner-32 Alias.php fixed types in phpdocs April 16, 2014
Octocat-spinner-32 CHANGELOG.md [DependencyInjection] Deprecate SimpleXMLElement April 02, 2014
Octocat-spinner-32 Container.php Merge branch '2.3' into 2.4 April 18, 2014
Octocat-spinner-32 ContainerAware.php [DependencyInjection] made ContainerAware class abstract. May 30, 2012
Octocat-spinner-32 ContainerAwareInterface.php [FramworkBundle] fix phpdoc of commands March 07, 2013
Octocat-spinner-32 ContainerAwareTrait.php Remove executable bit on PHP file November 19, 2013
Octocat-spinner-32 ContainerBuilder.php Merge branch '2.4' April 18, 2014
Octocat-spinner-32 ContainerInterface.php fixed types in phpdocs April 16, 2014
Octocat-spinner-32 Definition.php Merge branch '2.4' April 16, 2014
Octocat-spinner-32 DefinitionDecorator.php Merge branch '2.3' into 2.4 April 16, 2014
Octocat-spinner-32 ExpressionLanguage.php [ExpressionLanguage] renamed addFunction() to register() September 21, 2013
Octocat-spinner-32 IntrospectableContainerInterface.php fixed types in phpdocs April 16, 2014
Octocat-spinner-32 LICENSE update year on licenses January 07, 2014
Octocat-spinner-32 Parameter.php [DependencyInjection] tagged the public @api July 20, 2011
Octocat-spinner-32 README.md updated the composer install command to reflect changes in Composer September 18, 2013
Octocat-spinner-32 Reference.php Merge branch '2.3' into 2.4 April 16, 2014
Octocat-spinner-32 Scope.php updated license blocks March 31, 2012
Octocat-spinner-32 ScopeInterface.php fixed CS July 09, 2012
Octocat-spinner-32 SimpleXMLElement.php Merge branch '2.4' April 16, 2014
Octocat-spinner-32 TaggedContainerInterface.php fixed CS July 09, 2012
Octocat-spinner-32 Variable.php fixed CS June 08, 2011
Octocat-spinner-32 composer.json updated version to 2.5 November 24, 2013
Octocat-spinner-32 phpunit.xml.dist made usage of Composer autoloader for subtree-split unit tests November 09, 2012
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
$ phpunit
Something went wrong with that request. Please try again.