PHP code example of jeremykenedy / laravel-exception-notifier
1. Go to this page and download the library: Download jeremykenedy/laravel-exception-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/ */
jeremykenedy / laravel-exception-notifier example snippets
use App\Mail\ExceptionOccurred;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->report(function (\Throwable $exception): void {
if (! config('exceptions.emailExceptionEnabled')) {
return;
}
try {
Mail::send(new ExceptionOccurred([
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'trace' => $exception->getTrace(),
'url' => request()->url(),
'body' => request()->all(),
'ip' => request()->ip(),
]));
} catch (\Throwable $mailException) {
Log::error($mailException);
}
});
})
bash
php artisan exception-notifier:install --no-interaction
bash
php artisan vendor:publish --tag=laravelexceptionnotifier
bash
php artisan exception-notifier:update
bash
php artisan exception-notifier:update --layout=modern --theme=system --force
php artisan view:clear
bash
php artisan exception-notifier:update --layout=legacy --theme=light --force
php artisan view:clear
bash
php artisan view:clear
php artisan config:cache