Download the PHP package evelikto/di without Composer
On this page you can find all versions of the php package evelikto/di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package di
Short Description The most flexible (ευέλικτος!) dependency injection container for PHP
License MIT
Homepage https://evelikto.info/
Informations about the package di
evelikto-di
The most flexible (ευέλικτος!) dependency injection container of the world for PHP. Use just the features you want without runtime configuration costs.
Motivation
Although there are dozens of PHP DI libraries on GitHub, there is none which provides zero runtime-cost container configuration. Or configuration, which may easily be decomposed into smaller chunks, or which can be extended for use in different environments. Evelikto-DI goals are to combine performance, small size, maximal flexibility with an easy to use container config.
Installation
Evelikto is available via Composer/Packagist:
Or via Composer CLI:
Usage
Class \evelikto\di\AppContext is the default implementation of the DI container. The basic usage is to instantiate the container with the new-operator, passing the application config to the constructor, and then either passing the container to the framework, or to use the container to initialize the framework.
The configuration class must follow a few conventions:
- Every method in the class is considered to be a factory method.
- Every constant in the class is considered to be a configuration value.
- A constant can also represent an interface name alias (equal to the implementing concrete class).
- A method can also map an interface to a factory method.
The big advantage of this approach is the full freedom how to decompose your configuration. It also allows you to define multiple configurations in natural ways through native PHP means. And the best news is - you pay absolutely nothing for it in terms of CPU cycles!
Conclusion: 'class as config'-convention is extremely powerful, fast and easy to use.