Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2017-04-04 (6 days ago) | | Not yet rated by the users | | Total: Not yet counted | | Not yet ranked |
|
Description | | Author |
This class is a dependency injection container using closures.
It can set one or more callback functions that define code that creates objects of given types.
Classes that need to create objects of those types call this container class so it returns an object of the requested type. | |
|
|
Innovation award
Nominee: 1x |
|
Details
COCI
PHP Simple Injection, use classe in project.
Install
Composer install
{
"require":"carlosocarvalho/coci": "1.0.0"
}
Example use
<?php
require "vendor/autoload.php";
use COC\COCI\Injection;
$inj = new Injection;
Create Classes Injections with Agregration (Person)
Class Person(){
private $person ;
class function __construct(TypePerson $typePerson){
$this->person = $typePerson;
}
}
Create Classes Injections(TypePerson)
<?php
Class TypePerson(){
private $type;
setType($type){
$this->type;
}
getType(){
return $this->type;
}
}
Inject Classes Closure
<?php
$inj->set('TypePerson',function(){
return new TypePerson();
})
$inj->set('Person',function() use ($inj){
return new Person($inj->get('TypePerson'));
});
Inject Classes By Reflection
<?php
$inj->get('TypePerson');
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.