Ignition - A beautiful error page for Laravel Apps
In the local development, we see the Laravel error page a lot. Most probably the countless time in every day. You can do a beautiful representation of the error page, the will be more readable, eye-catching and nice to see. Ignition brings a beautiful error page of your application. Let’s see how we can integrate into our project.
Table of Contents
Open Table of Contents
Installation of Ignition
The package is included in laravel 6.xx
version already. However, if you use lower version than that, you need to pull via composer.
composer require --dev facade/ignition
Now, if you use Laravel 5.5
, 5.6
and 5.7
then you need to modify your app/Exceptions/Handler.php
file to load Ignition instead of the default Whoops page.
You need to add this method to your Handler.php
file:
protected function whoopsHandler()
{
try {
return app(\Whoops\Handler\HandlerInterface::class);
} catch (\Illuminate\Contracts\Container\BindingResolutionException $e) {
return (new \Illuminate\Foundation\Exceptions\WhoopsHandler)->forDebug();
}
}
Finally, publish your configurable file.
php artisan vendor:publish --provider="Facade\Ignition\IgnitionServiceProvider" --tag="config"
Basically it will publish the following files:
config/ignition.php
and config/flare.php
.
Now you are ready to check. Boot up your laravel server and make a mistake, then the error page should return something like this.
Cool, right?
Besides, you can send this exception error to flare app. If you want to know more how to set up, check here.
Let’s dig into ignition package what else we can do?
Configuration
There is a configuration section, where we can set most popular editors, i.g. phpstorm
, vscode
, sublime
and atom
. Besides, we can set a theme. By default, the light
theme is already set out of the box.
Identifying user data
If you pass your error data into flare app, it will pass the authenticated user’s data once the exception occurs. You can customize error details here-
class User extends Model {
//
public function toFlare(): array {
// Only `id` will be sent sent to Flare.
return [
'id' => $this->id
];
}
}
Read more here.
Notifications
If you want, you can get error notification in the different kinds of channels. In order to get notifications, you need to set up, check the setup details.
Besides all the facilities, it supports some other features out of the box. Hope you will like this package.
You will get a more in-depth article here.