spatie/laravel-ignition
Beautiful, customizable error page for Laravel 10+ apps (PHP 8.1+). Shows detailed exception screens, offers helpful solutions, and can share errors to Flare. With a Flare API key, it tracks production errors and sends notifications.
Installation:
composer require spatie/laravel-ignition
Ignition is automatically registered via Laravel's service provider discovery.
First Use Case:
Trigger an error in your Laravel app (e.g., 1/0 in a route or controller). Ignition will replace the default Laravel error page with a rich, interactive error page featuring:
Where to Look First:
php artisan vendor:publish --provider="Spatie\Ignition\IgnitionServiceProvider" --tag="ignition-config"
Edit config/ignition.php to customize behavior (e.g., disable solutions, adjust logging).flare.php for error tracking in production (see Flare docs).Local Development:
use App\Models\User; not found).Request, Response, Environment, and Logs to diagnose issues holistically.Error Handling:
Spatie\Ignition\Solutions\Solution class or register custom solutions in ignition.php:
'solutions' => [
\App\Solutions\MyCustomSolution::class,
],
public function handle($request, Closure $next) {
try {
return $next($request);
} catch (\Throwable $e) {
// Let Ignition handle it
throw $e;
}
}
Production Monitoring:
flare.php with your API key to track errors in production:
'key' => env('FLARE_API_KEY'),
'project_id' => env('FLARE_PROJECT_ID'),
ignition.php:
'ignore_exceptions' => [
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
],
Testing:
assert helpers in tests to verify error pages:
$response = $this->get('/error-route');
$response->assertSee('Ignition Error Page');
$this->app->singleton(Ignition::class, function () {
return Ignition::fake();
});
Performance:
Route::middleware(['ignition:off'])->group(function () {
// Ignition disabled here
});
'queue_reports' => env('QUEUE_REPORTS', false),
Livewire/Alpine:
Octane:
QUEUE_REPORTS is enabled to avoid blocking Swoole workers.Custom Views:
php artisan vendor:publish --provider="Spatie\Ignition\IgnitionServiceProvider" --tag="ignition-views"
resources/views/vendor/ignition/ to modify the error page layout.Logging:
laravel.log by default. Customize log channels in ignition.php:
'log' => 'single',
'log_level' => 'debug',
Security:
'ignored_headers' => [
'x-api-key',
'authorization',
],
'show_solutions' => env('APP_ENV') !== 'production',
Double Logging:
laravel.log due to HTML dumping in context().Middleware Order:
TrimStrings, ConvertEmptyStringsToNull) may not execute if placed after Ignition’s middleware.Spatie\Ignition\Middleware\Ignition) last in your $middleware stack:
protected $middleware = [
// Other middleware...
\Spatie\Ignition\Middleware\Ignition::class,
];
Flare Reporting:
queue_reports: true in ignition.php or manually trigger:
\Spatie\Ignition\Facades\Ignition::report($exception);
Livewire/Octane Conflicts:
Custom Exception Handling:
public function render($request, \Throwable $exception) {
if (app()->bound('ignition') && $exception instanceof \Throwable) {
return app('ignition')->render($request, $exception);
}
return parent::render($request, $exception);
}
Disable Ignition:
AppServiceProvider:
public function boot() {
if (app()->environment('local')) {
\Spatie\Ignition\Ignition::fake();
}
}
Inspect Context:
php artisan tinker to inspect Ignition’s context:
$context = \Spatie\Ignition\Facades\Ignition::context();
dd($context->all());
Clear Cache:
php artisan cache:clear
php artisan view:clear
Check for Conflicts:
Whoops, Debugbar) to isolate issues.Custom Solutions:
namespace App\Solutions;
use Spatie\Ignition\Solutions\Solution;
class UndefinedModelSolution extends Solution
{
public function solve($exception)
{
return 'Did you forget to define the `App\Models\'.classBasename($exception->model).'` model?';
}
public function matches($exception)
{
return $exception instanceof \ErrorException
&& str_contains($exception->getMessage(), 'Undefined class');
}
}
ignition.php:
'solutions' => [
\App\Solutions\UndefinedModelSolution::class,
],
Custom Context:
How can I help you explore Laravel packages today?