PHP code example of stanbridge / visual-exceptions

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

    

stanbridge / visual-exceptions example snippets


return [

    /*
    |--------------------------------------------------------------------------
    | Master Switch
    |--------------------------------------------------------------------------
    |
    | This option may be used to completely disable visual exceptions.
    |
    */

    'enabled' => env('VISUAL_EXCEPTIONS_ENABLED', env('APP_DEBUG')),

    /*
    |--------------------------------------------------------------------------
    | Path
    |--------------------------------------------------------------------------
    |
    | This is the URI path where visual exceptions will be accessible from.
    |
    */

    'path' => env('VISUAL_EXCEPTIONS_PATH', 'api/visual-exceptions'),

    /*
    |--------------------------------------------------------------------------
    | Storage
    |--------------------------------------------------------------------------
    |
    | This is where the temporary exception output will be stored.
    |
    */

    'storage' => 'visual-exceptions/latest.html',

    /*
    |--------------------------------------------------------------------------
    | Clear on Retrieve
    |--------------------------------------------------------------------------
    |
    | Use this option to clear the exception file after retrieving it.
    |
    */

    'clear_on_retrieve' => env('VISUAL_EXCEPTIONS_CLEAR', true),

    /*
    |--------------------------------------------------------------------------
    | Middleware
    |--------------------------------------------------------------------------
    |
    | Set middleware on the route.
    |
    */

    'middleware' => ['api'],
];

use \Illuminate\Support\Facades\Config;
use Stanbridge\VisualException\VisualException;

public function render($request, Throwable $exception)
{
    $render = $this->prepareResponse($request, $exception);
    
    if (Config::get('visual-exceptions.enabled')) {
        VisualException::capture($render);
    }
    
    return $render;
}
bash
php artisan vendor:publish --provider="Stanbridge\VisualException\VisualExceptionServiceProvider" --tag="config"