You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package contains a really minimalist dependency injection container that can be used to create aliases of instances
in existing containers. Alias-container is compatible with container-interop
and is meant to be used in conjunction with other containers. By itself, Alias-container does not store any entry. It can only be used
to create aliases of instances stored in other containers.
You can use AliasContainer to add support for alias for any container that does not support this feature.
Installation
Before using AliasContainer in your project, add it to your composer.json file:
The value is the identifier of the entry that will be aliased
Fetching entries from the container
Fetching entries from the container is as simple as calling the get method:
$myInstance = $aliasContainer->get('myAlias');
Adding aliases to the container
You can add new aliases using the set method.
$aliasContainer->set('newAlias', 'myInstance');
Note that it is more efficient to initialize aliases in the container
than calling recursively the set method.
Removing aliases from the container
You can add new aliases using the remove method.
$aliasContainer->remove('myAlias');
Why the need for this package?
This package is part of a long-term effort to bring interoperability between DI containers. The ultimate goal is to
make sure that multiple containers can communicate together by sharing entries (one container might use an entry from another
container, etc...)
About
This package contains a really minimalist dependency injection container that can be used to create aliases of instances in existing containers.