PHP code example of pikart / laravel-hooks
1. Go to this page and download the library: Download pikart/laravel-hooks 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/ */
pikart / laravel-hooks example snippets
HookManager::register('hook_name', function( array $args ) {
return 'Hello world';
}, 10);
HookManager::register('hook_name', SomeHookClass::class, 10);
HookManager::register('hook_name', new SomeHookClass::class, 10);
HookManager::register(SomeHookInterface::class, SomeHookClass::class, 10);
$output = HookManager::hook('hook_name');
$user = User::find(1);
$output = HookManager::hook('hook_name', [
'user' => $user]);
$output = HookManager::hook(SomeHookInterface::class);
$user = User::find(1);
$output = HookManager::hook(SomeHookInterface::class, [
'user' => $user]);
$user = User::find(1);
$output = HookManager::hook(SomeHookInterface::class, [
'user' => $user], 'someMethod');
$hooks = HookManager::get(SomeHookInterface::class);
$hooks = HookManager::get(SomeHookInterface::class, [
'user' => $user
]);
$hooks = HookManager::getRaw(SomeHookInterface::class);
bash
php artisan vendor:publish --provider="Pikart\LaravelHooks\HookServiceProvider"