Download the PHP package kodcube/dependency-injection without Composer
On this page you can find all versions of the php package kodcube/dependency-injection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kodcube/dependency-injection
More information about kodcube/dependency-injection
Files in kodcube/dependency-injection
Package dependency-injection
Short Description Dependency Injection Container
License
Informations about the package dependency-injection
Dependency Injection Container / Service Locator / Object Builder
This package is Recursive Dependency Injection Container (DiC) / Service Locator / Object Builder
It has been designed to take it's dependency configuration map as part of it's construction, so rather than setting up all the dependencies at runtime they can be loaded from a configuration file or files.
So as long as you can create an array, the configuration is injected at construction.
Main Features
- Build a Service/Object/Class based on a class name or alias
- Build a Class/Object that requires other dependencies
- Cache built Service/Object/Class for reuse in other classes (e.g. Database Connections)
- Build a Object/Class with a combination of passed and required dependencies
- Recursive Object Creation
Limitations
- Does not inject dependencies for methods other than __constructor
- Does not inject dependencies for setters
Requirements
- PHP 7
-
container-interop/container-interop
- Usage - Basic usage examples
- Create Container
- Get Object from Container
- Check if Alias\Class Exists in Container
- Make Object
- Methods
- Aliases
- AutoWiring
Usage
Create Container
Get Object from Container using an alias
Using Alias
Using Class Name
Using Interface Name (requires dependency map)
Check if Alias\Class Exists in Container
Make Object
Make a object using the DiC using passed arguments.
This will also take advantage of the autowiring properties of the container.
Note: Objects created with additional arguments are not cached by the container.