Download the PHP package mouf/interop.symfony.di without Composer
On this page you can find all versions of the php package mouf/interop.symfony.di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mouf/interop.symfony.di
More information about mouf/interop.symfony.di
Files in mouf/interop.symfony.di
Package interop.symfony.di
Short Description This package contains an implementation of the Symfony 2 DI container that can be extended using other DI containers (from other frameworks).
License MIT
Homepage http://mouf-php.com/packages/mouf/interop.symfony.di
Informations about the package interop.symfony.di
Extensible DI container for Symfony2
This package contains an ExtensibleContainer
class that extends the Container
class of Symfony 2.
The extended class will let you add additional dependency injection containers (DIC) to Symfony 2's container.
This means that when you develop a Symfony 2 application, you are no more forced into using Symfony's DIC only. You can now use add any DIC you want!
How does it work?
To make this work, you must put the Symfony2 container inside a composite container that will contain other containers.
There is a great implementation of a CompositeContainer
in the Acclimate projet.
The typical workflow will look like this:
The router (or any other component) will ask for an instance to the ExtensibleContainer
. The ExtensibleContainer
will forward the call to the CompositeContainer
that will in turn forward the call to any other container
in the CompositeContainer
. To enter the CompositeContainer
, a container must respect the ContainerInterface
as defined in the container-interop project.
Installation
The ExtensibleContainer
is distributed as a Composer package.
You will also typically need Acclimate (for the composite container) and other containers.
In your app/AppKernel.php
file, add these 2 methods:
Your DI container must respect the ContainerInterface
provided by the container-interop project.
What DI containers can I plug in Symfony?
Out of the box, you can plug these DI containers, because they respect the ContainerInterface
interface:
- Mouf2 (http://mouf-php.com)
- PHP-DI 4.1+ (https://github.com/auraphp/Aura.Di)
- PimpleInterop (https://github.com/moufmouf/pimple-interop, a wrapper around Pimple)
But wait! Thanks to Jeremy Lindblom and its awesome Acclimate package, you can now take almost any dependency injection container out there, and get an adapter on that container that respects the ContainerInterface
interface.