Download the PHP package chkt/eve without Composer
On this page you can find all versions of the php package chkt/eve. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package eve
Short Description A minimalistic and flexible and powerful dependency injection system
License MIT
Informations about the package eve
eve
A minimalistic, flexible and powerful dependency injector
eve is a small (~250 lines of executable code), self contained dependency injector choosing a configuration approach over reflection, annotations or similar meta-programming techniques.
Dependencies are defined in code alongside their classes offering a high level of control over object creation, sharing and caching.
Install
You can use composer to install eve.
Command line
composer.son
Alternatively you can clone the github repository to a place of your liking.
Basic usage
The injector depends on a couple of helpers to resolve and inject dependencies.
All of these are combined into the InjectorDriver
.
The first line creates the BaseFactory
, which supplies the basic means of instantiating objects.
In the second line the BaseFactory is used to create the InjectorDriverFactory
,
which in line three creates the InjectorDriver
.
The types of injectable objects depend on the configuration of the driver. The options for configuring the driver are listed in the driver folder.
Using the injector is straightforwand.
The optional second argument allows additional configuration options to be passed to the injector.
Since eve is not using reflection or other meta-programming techniques,
it depends on injectable objects implementing \eve\inject\IInjectable
,
which defines the single static method getDependencyConfig
.
The getDependencyConfig
method defines what kind of arguments new instances
of the class are to be created with.
Dependencies can either be arrays with a 'type'
and one or more additional keys, or be
defined using entity syntax, referring to dependencies through url formatted strings.
In the example above the injector will inject itself as the first constructor argument.
The second argument is an object registered as 'providableObject'
at the provider named 'providerName'
and configured with key=value
.
If the injector was supplied with an array containing a property named 'options'
,
as its second argument, it is supplied as the third argument.
If no second argument was supplied to the injector or it did not contain an 'options'
property,
getDependencyConfig
returns an empty array as the third argument.