PHP code example of nabeghe / file-hooker

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

    

nabeghe / file-hooker example snippets




use Nabeghe\FileHooker\FileHooker;

// This is a custom object called angler. It is sent as the second argument to the callbacks.
$angler = new stdClass();
$angler = new FileHooker($angler);

// Add a new path where the hooks are located.
$hooker->add(__DIR__.'/hooks');

// Action
$hooker->action('print', ['text' => 'Hi']);

// Filter
$result = $hooker->filter('remove_spaces', ['Hadi Akbarzadeh']);
echo $result;



return function ($data, $angler) {
    echo $data['text'];
};



return function ($data, $angler) {
    $data = str_replace(' ', '', $data[0]);
    return $data;
};