PHP code example of pulsehub / laravel

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

    

pulsehub / laravel example snippets


->withExceptions(function (Exceptions $exceptions) {
    \PulseHub\Laravel\Facades\PulseHub::registerExceptionHandler($exceptions);
})

use PulseHub\Laravel\Facades\PulseHub;

try {
    importInvoices($batchId);
} catch (Throwable $e) {
    PulseHub::context(['batch' => $batchId])
        ->user(auth()->id(), auth()->user()?->email)
        ->reportException($e);
}

// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\PulseHub\Laravel\Middleware\PulseHubMiddleware::class);
})

use PulseHub\Laravel\Events\ReportSent;
use PulseHub\Laravel\Events\ReportFailed;

Event::listen(ReportSent::class,   fn ($e) => /* ... */);
Event::listen(ReportFailed::class, function ($e) {
    if ($e->category() === 'auth_invalid') {
        // page the on-call: PulseHub key is broken
    }
});
bash
php artisan pulsehub:test
bash
php artisan pulsehub:report        # queue (default)
php artisan pulsehub:report --sync # send immediately