| Recommend this page to a friend! | 
| Info | Documentation | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 49 | All time:  10,738 This week: 96 | ||||
| Version | License | PHP version | Categories | |||
| coci 1.0 | GNU General Publi... | 5 | PHP 5, Design Patterns | 
| Description | Author  | |
This class is a dependency injection container using closures.  | 
PHP Simple Injection, use classe in project.
Composer install
  {
     "require":"carlosocarvalho/coci": "1.0.0"
  }
  
<?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');
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Class | Class source | |||
| Data | Auxiliary data | |||
| Doc. | Documentation | |||
| / | vendor | / | composer | 
| File | Role | Description | 
|---|---|---|
|    | 
Aux. | Auxiliary script | 
|    | 
Aux. | Auxiliary script | 
|    | 
Aux. | Auxiliary script | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Data | Auxiliary data | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.