#TIL : Getting back Whoops error pages in Laravel 9


13 Mar 2022 / by KhanhIceTea

Laravel 9 uses "Spatie/Ignition" as default error handling pages , which is beatiful but bloated within add-on service like Flare.

So if you want to get back the good-old "Whoops" error pages, this tutorial is for you :D

First, we remove "spatie/ignition" from composer packages

$ composer remove "spatie/laravel-ignition"

Then, add 3 lines in the boot function of AppServiceProvider

use Illuminate\Contracts\Foundation\ExceptionRenderer;
use Illuminate\Foundation\Exceptions\Whoops\WhoopsExceptionRenderer;

class AppServiceProvider extends ServiceProvider {
    public function boot()
    {
        // Add 3 lines below between boot function
        if (config('app.debug')) {
            $this->app->bind(ExceptionRenderer::class, WhoopsExceptionRenderer::class);
        }
    }
}

And last but not least, open the config/app.php then add to this line to array config (try to replace the name of Editor you use in this list )

    ...
    'editor' => 'vscode'
    ...

Now try to add this line to second line in web.php route file to test

$x = 1 / 0;

Sound good ?