PHP code example of rawnoq / laravel-exceptions

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

    

rawnoq / laravel-exceptions example snippets


use Rawnod\Exceptions\ExceptionRenderer;
use Illuminate\Foundation\Configuration\Exceptions;

return Application::configure(basePath: dirname(__DIR__))
    // ... other configuration
    ->withExceptions(function (Exceptions $exceptions): void {
        $exceptions->render(function (\Throwable $e, $request) {
            if ($request->is('api/*')) {
                return app(ExceptionRenderer::class)->render($e);
            }
        });
    })->create();
bash
php artisan vendor:publish --tag=exceptions-config
bash
php artisan vendor:publish --tag=exceptions-lang