Symfony Dependency Injection Configuration Bundle
This bundle makes it possible to easily customise existing service definitions
defined in third-party bundles., (*1)
Note: Many bundles offer their own configuration options to customise how
their services are configured. Please refer to their documentation first for
available configuration options before using this bundle., (*2)
Installation
Use Composer to install the bundle:, (*3)
$ composer require xabbuh/di-configuration-bundle
Then, enable it in your application:, (*4)
// app/AppKernel.php
// ...
public function registerBundles()
{
$bundles = array(
// ...
new Xabbuh\DiConfigurationBundle\XabbuhDiConfigurationBundle(),
);
// ...
return $bundles;
}
Configuration
Note: You can only change the configuration of existing services. The bundle
is not meant to be used to configure new services. If you want to add your own
services use [the built-in Symfony configuration mechanisms][2]., (*5)
Customize Service Definitions
Change the class name of a service:, (*6)
xabbuh_di_configuration:
logger:
class: app.logger
If you do not want to configure any other options of a particular service, you
can omit the class
key:, (*7)
xabbuh_di_configuration:
monolog.logger: app.logger
You can replace existing arguments using the arguments
key. A reference to
another service needs to be the service id prefixed with the @
character:, (*8)
xabbuh_di_configuration:
locale_listener:
arguments:
- de
- @app.router
You can use the index
key for an argument if you do not want to replace all
arguments, but want to skip some of them. The following example only replaces
the first and the third argument of the locale_listener
service, but leaves
the second argument as is:, (*9)
xabbuh_di_configuration:
locale_listener:
arguments:
- de
- index: 2
value: @app.request_stack