Track Your Errors using Discord Webhook on any Laravel App
composer require tomatophp/laravel-discord-error-tracker
on your env
DISCORD_ERROR_WEBHOOK_ACTIVE=true #Enable And Disable Log
DISCORD_ERROR_EVERYONE=true #Enable And Disable @everyone alert on the message
DISCORD_ERROR_WEBHOOK= #Your Discord Server Channel Webhook URL
if you are using Laravel 11 or above use this code, at bootstrap/app.php
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use TomatoPHP\LaravelDiscordErrorTracker\Services\DiscordServices;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
DiscordServices::handler($exceptions);
})->create();
if you are using Laravel 10, use this code, at app\Exceptions\Handler.php
<?php
namespace App\Exceptions;
use TomatoPHP\LaravelDiscordErrorTracker\Services\DiscordServices;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->reportable(function (Throwable $exception) {
DiscordServices::handler($exception);
});
}
}
this way will log all errors on your app, if you like to log selected error you can use this method direct
<?php
use TomatoPHP\LaravelDiscordErrorTracker\Services\DiscordServices;
$exception = new \Exception('Test Exception');
DiscordServices::handler($exception);
you can publish config file by use this command
php artisan vendor:publish --tag="laravel-discord-error-tracker-config"
Please see CHANGELOG for more information on what has changed recently.
Please see SECURITY for more information about security.
The MIT License (MIT). Please see License File for more information.
if you like to run PEST
testing just use this command
composer test
if you like to fix the code style just use this command
composer format
if you like to check the code by PHPStan
just use this command
composer analyse
Checkout our Awesome TomatoPHP