Download the PHP package mpstyle/container without Composer
On this page you can find all versions of the php package mpstyle/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mpstyle/container
More information about mpstyle/container
Files in mpstyle/container
Package container
Short Description Lazy and naive container for the dependency injection for PHP 7
License LGPL v3
Informations about the package container
Container
Lazy and naive container for the dependency injection. Require PHP >=7.0.
Use the flyweight design pattern to store a single instance of injectable classes.
Installation
Simply add a dependency on mpstyle/container to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a development-time dependency on MpStyle Container:
or using console:
Usages
Simple usage of the container:
Closure
It's possible to pass a Closure to the container which contains the logic to instantiate an object:
INI File
It's possible to create a container using a PHP file collecting definitions:
definitions.ini:
In your PHP code:
Closure or object are not supported using INI file.
PHP File
It's possible to create a container using a PHP file collecting configurations:
definitions.php:
In your PHP code:
Singleton instance
Using the wrapper of singleton instance:
Version
- 1.5.1: Removed unused classes.
- 1.5.0: Improved performance and tests.
- 1.4.0: Added support to load definitions from INI file and to load a container from PHP configuration file.
- 1.3.1: Little fixes.
- 1.3.0: Improved performance and stability, deprecated Container#get(string $key) method, use Container#getInstance(string $key) instead.
- 1.2.0: Added Closure support to the container.
- 1.1.0
- 1.0.0