PHP code example of hugomyb / filament-error-mailer

1. Go to this page and download the library: Download hugomyb/filament-error-mailer 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/ */

    

hugomyb / filament-error-mailer example snippets


return [
    'email' => [
        'recipient' => ['[email protected]'],
        'bcc' => [],
        'cc' => [],
        'subject' => 'An error has occurred - ' . config('app.name'),
    ],

    'disabledOn' => [
        //
    ],

    'cacheCooldown' => 10, // in minutes

    'webhooks' => [
        'discord' => env('ERROR_MAILER_DISCORD_WEBHOOK'),

        // Additional generic webhook URLs the plugin will POST the raw
        // error details JSON to. Can also be set via env (CSV).
        'endpoints' => array_values(array_filter(array_map('trim', explode(',', (string) env('ERROR_MAILER_WEBHOOK_URLS', ''))))),

        'message' => [
            'title' => 'Error Alert - ' . config('app.name'),
            'description' => 'An error has occurred in the application.',
            'error' => 'Error',
            'file' => 'File',
            'line' => 'Line',
            'details_link' => 'See more details'
        ],
    ],

    'storage_path' => storage_path('app/errors'),

    'ignore' => [
        'levels' => [
            // 'debug',
            // 'info',
        ],
        'exceptions' => [
            // \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
        ],
    ],
];

use Hugomyb\FilamentErrorMailer\FilamentErrorMailerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other configuration
        ->plugins([
            FilamentErrorMailerPlugin::make(),
        ]);
}

'email' => [
    'recipient' => ['[email protected]', '[email protected]'],
    'bcc' => ['[email protected]'],
    'cc' => [],
    'subject' => 'Error Alert - ' . config('app.name'),
],

'webhooks' => [
    'discord' => env('ERROR_MAILER_DISCORD_WEBHOOK'),

    'message' => [
        'title' => 'Error Alert - ' . config('app.name'),
        'description' => 'An error has occurred in the application.',
        'error' => 'Error',
        'file' => 'File',
        'line' => 'Line',
        'details_link' => 'View Details',
    ],
],

'webhooks' => [
    'discord' => env('ERROR_MAILER_DISCORD_WEBHOOK'),

    'endpoints' => [
        'https://hooks.example.com/error',
        'https://n8n.example.com/webhook/abc123',
        env('CUSTOM_MONITORING_WEBHOOK'),
    ],

    // ...
],

'ignore' => [
    // Ignore specific log levels
    'levels' => [
        'debug',
        'info',
        // 'warning',
        // 'error',
    ],

    // Ignore specific exception types
    'exceptions' => [
        \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
        \Illuminate\Validation\ValidationException::class,
        \Illuminate\Auth\AuthenticationException::class,
    ],
],

'disabledOn' => [
    'local',
    'testing',
],

'cacheCooldown' => 10, // in minutes

'storage_path' => storage_path('app/errors'),

protected function schedule(Schedule $schedule)
{
    // Delete errors older than 3 months
    $schedule->call(function () {
        $storagePath = config('error-mailer.storage_path');
        $files = File::files($storagePath);

        foreach ($files as $file) {
            if ($file->getMTime() < now()->subMonths(3)->timestamp) {
                File::delete($file->getRealPath());
            }
        }
    })->daily();
}

return [
    // Email notification settings
    'email' => [
        'recipient' => ['[email protected]'],
        'bcc' => [],
        'cc' => [],
        'subject' => 'Error Alert - ' . config('app.name'),
    ],

    // Environments where notifications are disabled
    'disabledOn' => [
        // 'local',
        // 'testing',
    ],

    // Cooldown period in minutes
    'cacheCooldown' => 10,

    // Webhook configuration
    'webhooks' => [
        'discord' => env('ERROR_MAILER_DISCORD_WEBHOOK'),

        // Additional URLs to POST the raw error JSON to.
        'endpoints' => array_values(array_filter(array_map('trim', explode(',', (string) env('ERROR_MAILER_WEBHOOK_URLS', ''))))),

        'message' => [
            'title' => 'Error Alert - ' . config('app.name'),
            'description' => 'An error has occurred in the application.',
            'error' => 'Error',
            'file' => 'File',
            'line' => 'Line',
            'details_link' => 'View Details',
        ],
    ],

    // Storage path for error JSON files
    'storage_path' => storage_path('app/errors'),

    // Error filtering
    'ignore' => [
        'levels' => [
            // 'debug',
            // 'info',
        ],
        'exceptions' => [
            // \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
        ],
    ],
];
bash
php artisan vendor:publish --tag="error-mailer-config"
bash
php artisan vendor:publish --tag="error-mailer-views"