PHP code example of mascame / hooky

1. Go to this page and download the library: Download mascame/hooky 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/ */

    

mascame / hooky example snippets


class MyHook implements \Mascame\Hooky\HookContract {

    public function handle($data, $next)
    {
        $data = 'test';

        return $next($data);
    }
    
}


$hook = new \Mascame\Hooky\Hook();
$hookName = 'bar';
$someData = 'foo'; // This will be sent to handlers, where they can manipulate it

$hook->to($hookName, [MyHook::class, AnotherHook::class]);

$data = $hook->fire($hookName, $someData);