PHP code example of hongyukeji / laravel-hook

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

    

hongyukeji / laravel-hook example snippets


    'Hongyukeji\Hook\HookServiceProvider',
    'Hongyukeji\Hook\HookBladeServiceProvider', 

    'Hook' => Hongyukeji\Hook\Facades\Hooks::class,

Hook::action('my.hook', 'awesome');
 
$value = Hook::filter('my.hook', 'awesome');

Hook::addFilter('my.hook', function($what) {
    $what = 'not '. $what;
    return $what;
}, 20, 1);

Hook::addAction('my.hook', function($what) {
    $what = Hook::filter('my.hook', 'awesome');
    echo 'You are '. $what;
});

Hook::addAction('my.hook', function($what) {
    echo 'You are '. $what;
}, 20, 1);