| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | 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');
|  Files (16) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  COC (1 file) | ||||
|  Database (1 file) | ||||
|  tests (1 file) | ||||
|  vendor (1 file, 1 directory) | ||||
|    .travis.yml | Data | Auxiliary data | ||
|    composer.json | Data | Auxiliary data | ||
|    composer.lock | Data | Auxiliary data | ||
|  index.php | Class | Class source | ||
|    phpunit.xml | Data | Auxiliary data | ||
|    README.md | Doc. | Documentation | ||
|  Files (16) | / | vendor | / | composer | 
| File | Role | Description | 
|---|---|---|
|    autoload_classmap.php | Aux. | Auxiliary script | 
|    autoload_namespaces.php | Aux. | Auxiliary script | 
|    autoload_psr4.php | Aux. | Auxiliary script | 
|  autoload_real.php | Class | Class source | 
|  ClassLoader.php | Class | Class source | 
|    installed.json | 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. | 
|  Install with Composer | 
| 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.
 If you know an application of this package, send a message to the author to add a link here.