Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions components/dependency_injection/compilation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ processed when the container is compiled at which point the Extensions are loade
// ...
$container->compile();

.. note::

When loading a config file that uses an extension alias as a key, the
extension must already have been registered with the container builder
or an exception will be thrown.

The values from those sections of the config files are passed into the first
argument of the ``load`` method of the extension::

Expand Down Expand Up @@ -239,6 +245,25 @@ but also load a secondary one only if a certain parameter is set::
}
}

.. note::

Just registering an extension with the container is not enough to get
it included in the processed extensions when the container is compiled.
Loading config which uses the extension's alias as a key as in the above
examples will ensure it is loaded. The container builder can also be
told to load it with its
:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::loadFromExtension`
method::

use Symfony\Component\DependencyInjection\ContainerBuilder;

$container = new ContainerBuilder();
$extension = new AcmeDemoExtension();
$container->registerExtension($extension);
$container->loadFromExtension($extension->getAlias());
$container->compile();


.. note::

If you need to manipulate the configuration loaded by an extension then
Expand Down