1. Go to this page and download the library: Download grithin/control-path 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/ */
grithin / control-path example snippets
use \Grithin\ServiceLocator;
$sl = new ServiceLocator();
$cp = new ControlPath(__DIR__.'/test_files/app1/', $sl->injector_get());
$returns = $cp->load('/section1/page');
namespace App\Control\section1;
class Controller{
# always called, but return is not used
public function __construct(){
}
# always called, return is used
public function _always(){
}
}
# within a method/constructor
function __construct($ControlPath){}
# within a closure
return function($ControlPath){}
class Controller{
function __construct($share){
$share->do_x = function(){
$this->do_x();
};
}
protected function do_x(){
echo 'bob';
}
}
($share->do_x)();
class Controller{
public function __construct($Flow){
$Flow->stop();
}
}
$return_handler = function($return, $flow){
# there can be no "bill"'s, only bob's
if($return == 'bill'){
$flow->stop();
}
}
$ControlPath->load('/section1/page', ['return_handler'=>$return_handler]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.