PHP code example of guanguans / laravel-exception-notify

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

    

guanguans / laravel-exception-notify example snippets




use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;

return Application::configure(basePath: \dirname(__DIR__))
    ->withExceptions(static function (Exceptions $exceptions): void {
        $exceptions
            // ->dontReportWhen(static fn (Throwable $throwable) => collect([
            //     \Symfony\Component\HttpKernel\Exception\HttpException::class,
            //     \Illuminate\Http\Exceptions\HttpResponseException::class,
            // ])->contains(static fn (string $exception): bool => $throwable instanceof $exception))
            ->dontReport([
                \Symfony\Component\HttpKernel\Exception\HttpException::class,
                \Illuminate\Http\Exceptions\HttpResponseException::class,
            ]);
    })->create();



use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;

public function boot(): void
{
    ExceptionNotify::skipWhen(static fn (\Throwable $throwable) => collect([
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Http\Exceptions\HttpResponseException::class,
    ])->contains(static fn (string $exception): bool => $throwable instanceof $exception));
}



use Guanguans\LaravelExceptionNotify\Contracts\ChannelContract;
use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;
use Illuminate\Container\Container;

public function boot(): void
{
    ExceptionNotify::extend('YourChannelName', function (Container $container): ChannelContract {
        return 'Instance of the `Guanguans\LaravelExceptionNotify\Contracts\ChannelContract`.';
    });
}
shell
php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider" --ansi -v
shell
php artisan exception-notify:test --channel=log --job-connection=sync
php artisan exception-notify:test
php artisan exception-notify:test -v