PHP code example of buffalokiwi / buffalotools_ioc

1. Go to this page and download the library: Download buffalokiwi/buffalotools_ioc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

buffalokiwi / buffalotools_ioc example snippets


//..Create the IOC container
$ioc = new IOC();

//..Add some interface to the container, and supply a factory for creating new instances 
$ioc->addInterface( \namespace\to\SomeAmazingClass::class, function() {
  return new SomeAmazingClass();
});

//..Retrieve the class instance by supplying the same interface or class name as supplied to addInterface()
$amazing = $ioc->getInstance( \namespace\to\SomeAmazingClass::class );