PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of carlos carvalho   COCI   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: COCI
Dependency injection container using closures
Author: By
Last change:
Date: 7 years ago
Size: 1,783 bytes
 

Contents

Class file image Download

COCI

PHP Simple Injection, use classe in project.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

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');