PHP code example of irabbi360 / laravel-log-notifier

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

    

irabbi360 / laravel-log-notifier example snippets


return [
    'enabled' => env('LOG_NOTIFIER_ENABLED', true),
    
    'levels' => ['error', 'critical', 'alert', 'emergency'],
    
    'notification' => [
        'title' => 'Laravel Error 🚨',
        'icon' => '/vendor/log-notifier/icon.png',
        'sound' => true, // Play sound on critical errors
    ],
];



use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Irabbi360\LaravelLogNotifier\LogNotifierWatcher;

return Application::configure(basePath: dirname(__DIR__))
    ->withConfiguration()
    ->withRouting()
    ->withMiddleware(function (Middleware $middleware) {
        // ... your middleware
    })
    ->withExceptions(function (Exceptions $exceptions) {
        // Register Log Notifier exception handler
        LogNotifierWatcher::handles($exceptions);
    })
    ->create();

// Any unhandled exception will trigger a toast notification
throw new Exception('Something failed!');

// Database errors
DB::connection()->getPdo();

// Model validation errors
User::findOrFail($invalidId);

// Any other exception in your app...

// config/log-notifier.php
'enabled' => env('LOG_NOTIFIER_ENABLED', true),

// config/log-notifier.php
'levels' => [
    'emergency',  // System is unusable
    'alert',      // Action must be taken immediately
    'critical',   // Critical condition
    'error',      // Error condition
    // 'warning', 'notice', 'info', 'debug' - not monitored by default
],

// config/log-notifier.php
'levels' => ['emergency', 'alert', 'critical', 'error'],

'notification' => [
    'sound' => true,
],
bash
php artisan vendor:publish --tag="log-notifier-config"