Download the PHP package artoodetoo/container without Composer
On this page you can find all versions of the php package artoodetoo/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download artoodetoo/container
More information about artoodetoo/container
Files in artoodetoo/container
Informations about the package container
Container
Yet another service container
Container DOES NOT use reflection and type hint information in any form.
Features
Container keep two kind of values: services and parameters.
Service will instantiated when you call call it by name. Usually service is object type, but not nesessary. Mind it as "product" of some routine.
Methods: get()
and set()
.
Parameters are not instantiating, they just stored and retrieved.
Methods: getParameter()
and setParameter()
.
Install
To install with composer:
Basic Usage
Configuration
There are special configuraton sections:
- root used to store basic values, which can be substituted into service definition.
shared
node defines shared services. after it created once it can be retrieved many times.multiple
node defines new instance created on every get() call
In other sections you can store any kind of information and retrieve it in dot notation (see below).
Simple service definition
Parameters substitution
Factory method
Container injection
There are two ways to inject container into service instance:
- Add interface
R2\DependencyInjection\ContainerAwareInterface
to service class and define setContainer() method. - Substitute container in constructor parameters. It is special name
CONTAINER
:
Parameters and dot notation:
Notes and Limits
Any part of configuration can be read by getParameter, including special sections shared
and multiple
.
As for now, substitution patterns work in service production only.
Only parameters from config root can be used in substitution patterns.
License
The Container is open-source software, licensed under the MIT license