spatie/ignition
Beautiful, customizable error page for PHP apps. Register in one line to get a rich exception UI with stack traces, code snippets, context, and dark mode. Works standalone; see Laravel Ignition, Symfony bundle, and more integrations.
Installation:
composer require spatie/ignition
For Laravel, use spatie/laravel-ignition instead (preferred for Laravel projects).
Basic Registration (in bootstrap/app.php or equivalent):
use Spatie\Ignition\Ignition;
Ignition::make()->register();
First Use Case:
throw new Exception('Test error');).Environment-Specific Configuration:
// Disable in production (default)
Ignition::make()
->shouldDisplayException(app()->environment('local'))
->register();
// Force dark mode
Ignition::make()
->setTheme('dark')
->register();
Solution Providers:
// Register a solution provider
Ignition::make()
->addSolutionProviders([
\App\Providers\CustomSolutionProvider::class,
])
->register();
Flare Integration (for error monitoring):
Ignition::make()
->runningInProductionEnvironment(app()->environment('production'))
->sendToFlare(config('services.flare.key'))
->configureFlare(function ($flare) {
$flare->context('User', auth()->id());
})
->register();
AI-Powered Solutions (optional):
$aiProvider = new \Spatie\Ignition\Solutions\OpenAi\OpenAiSolutionProvider(config('services.openai.key'));
$aiProvider->applicationType('Laravel 10.x');
$aiProvider->useCache(cache());
Ignition::make()
->addSolutionProviders([$aiProvider])
->register();
spatie/laravel-ignition for seamless integration with Laravel’s exception handling.symfony-ignition-bundle or ignition module).index.php or public/index.php).App\Exceptions\Handler. Place its registration before the Handler in bootstrap/app.php.Registration Timing:
boot()).bootstrap/app.php before the AppServiceProvider.Production Leaks:
shouldDisplayException(false) in production.->configureFlare(function ($flare) {
$flare->censorRequestBodyFields(['password', 'api_token']);
})
AI Solution Latency:
useCache().$aiProvider->useCache(cache(), 0); // Disable caching (or set TTL=0)
Dark Mode Conflicts:
!important sparingly or inspect Ignition’s generated classes (e.g., .ignition-dark).Disable Ignition Temporarily:
Ignition::make()->shouldDisplayException(false)->register();
Useful for testing if Ignition is interfering with other error handlers.
Inspect Raw Data:
Ignition stores the exception data in $_ignition_exception. Access it in middleware or Blade:
dd($_ignition_exception); // Debug the raw exception object
Clear Cached Solutions: If AI solutions seem stale, clear the cache:
php artisan cache:clear
Custom Solution Providers:
HasSolutionsForThrowable to add domain-specific fixes.Flare Middleware:
class LogMiddleware implements \Spatie\FlareClient\FlareMiddleware\FlareMiddleware {
public function handle($report, $next) {
\Log::error($report->getMessage());
return $next($report);
}
}
Override Templates:
php artisan vendor:publish --tag=ignition-assets
resources/js/ignition/ignition.js or resources/css/ignition/ignition.css.Localization:
php artisan vendor:publish --tag=ignition-translations
resources/lang/vendor/ignition/en/messages.php.Pair with Laravel Telescope: Use Ignition for development and Telescope for production monitoring (they integrate seamlessly).
GitHub Actions: Automate error reporting in CI:
- name: Report errors to Flare
run: php artisan flare:report --env=testing
if: failure()
Performance: Ignition adds ~50KB to your assets. For high-traffic apps, consider:
Ignition::make()->registerOnlyInLocalEnvironment()->register();
How can I help you explore Laravel packages today?