PHP code example of alizharb / laravel-hooks
1. Go to this page and download the library: Download alizharb/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/ */
alizharb / laravel-hooks example snippets
use AlizHarb\LaravelHooks\Facades\Hook;
// Register
Hook::addAction('order.created', function ($order) {
Log::info("Order #{$order->id} created");
});
// Dispatch
Hook::doAction('order.created', $order);
use AlizHarb\LaravelHooks\Attributes\HookFilter;
class contentModifier
{
#[HookFilter('content.render', priority: 20)]
public function addSignature($content)
{
return $content . "\n\n-- Sent via Laravel Hooks";
}
}