PHP code example of 00f100 / fcphp-dispach

1. Go to this page and download the library: Download 00f100/fcphp-dispach 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/ */

    

00f100 / fcphp-dispach example snippets



use FcPhp\Di\Facades\DiFacade;
use FcPhp\Controller\Controller;

// Class example ...
class ExampleController extends Controller
{
    public function findAll($foo, $bar)
    {
        return compact('foo', 'bar');
    }
}
// Configure class into FcPhp Di
$di = DiFacade::getInstance();
$di->set('ExampleController', 'ExampleController');



use FcPhp\Dispach\Facades\DispachFacade;
// Init Dispach
$instance = DispachFacade::getInstance();

/*
    Return ExampleController->findAll('foo_value', 'bar_value'):
    Array (
        'foo' => 'foo_value',
        'bar' => 'bar_value'
    )
*/
print_r($instance->dispach('ExampleController@findAll', ['foo_value', 'bar_value']));