Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Ignition Laravel Package

spatie/laravel-ignition

Beautiful, customizable error page for Laravel apps (Laravel 10+ / PHP 8.1+). Ignition improves exception debugging with context and solutions, and can share errors to Flare for production tracking and notifications via an API key.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require spatie/laravel-ignition
    

    Ignition auto-registers via Laravel's service provider system—no manual configuration is required for basic usage.

  2. First Use Case: Trigger an error in your application (e.g., 1/0 in a route or controller). Ignition replaces Laravel’s default error page with an interactive, detailed error screen featuring:

    • Stack traces with collapsible sections.
    • Context data (request, session, variables).
    • Quick solutions (e.g., "Missing use statement?").
    • Copy-to-clipboard functionality for error details.
  3. Where to Look First:

    • Error Page: The UI itself (e.g., http://your-app.test/ignition for local testing).
    • Configuration: config/ignition.php (customize solutions, AI keys, or Flare integration).
    • Documentation: Flare’s Ignition Docs for advanced features.

Implementation Patterns

Daily Workflows

  1. Local Development:

    • Debugging: Ignition’s stack traces and context panels replace dd() or var_dump() for complex debugging. Use the "Copy Exception" button to share errors with teammates.
    • Quick Fixes: Click "Suggested Solutions" for common issues (e.g., missing use statements, route definitions).
    • Environment Context: Toggle the "Show Environment" button to inspect .env variables (redacted by default).
  2. Production Monitoring (Flare Integration):

    • Add your Flare API key to .env:
      FLARE_API_KEY=your_key_here
      
    • Errors auto-sync to Flare’s dashboard, including:
      • Request/response data.
      • Database queries (if using Flare’s query logging).
      • Performance metrics.
    • Trigger a Test Error: Use php artisan flare:test-error to verify setup.
  3. Customizing Solutions:

    • Extend Ignition’s "Suggested Solutions" with your team’s patterns:
      // app/Providers/IgnitionServiceProvider.php
      use Spatie\Ignition\Solutions\Solution;
      
      public function register()
      {
          Solution::extend('custom_solution', function () {
              return Solution::create('Custom Solution')
                  ->setDescription('Add this to your config file:')
                  ->setSolution('<code>...</code>');
          });
      }
      
  4. Artisan Commands:

    • Clear Ignition Cache:
      php artisan ignition:clear
      
    • Share Errors Publicly (Flare):
      php artisan flare:share
      
  5. Testing:

    • Mock Ignition in PHPUnit:
      use Spatie\Ignition\Ignition;
      
      public function testErrorPage()
      {
          Ignition::fake(); // Disable Ignition for the test
          // ... test code ...
      }
      

Integration Tips

  1. With Livewire:

    • Ignition automatically captures Livewire component errors with stack traces pointing to .blade.php files.
  2. With Queues:

    • Failed jobs show detailed payloads (decoded if serialized). Use the "Replay Job" button to debug queue workers.
  3. With API Testing:

    • Ignition’s error pages work for API routes. Use the "Response" tab to inspect raw HTTP responses.
  4. With Homestead/Sail:

    • Ignition’s "Sail Helper" detects missing sail commands and suggests fixes (e.g., sail artisan migrate).
  5. With IDEs:

    • Click the "Open in IDE" button to jump to the error’s file/line in PhpStorm, VSCode, or other editors.

Gotchas and Tips

Pitfalls

  1. Flare API Key Leaks:

    • Risk: Accidentally committing FLARE_API_KEY to version control.
    • Fix: Add .env to .gitignore and use Laravel’s .env.example for templates.
  2. Sensitive Data Exposure:

    • Risk: Context panels may expose passwords or tokens in logs/errors.
    • Fix: Configure ignition.php to redact sensitive keys:
      'redact' => [
          'password',
          'api_token',
          'secret_*',
      ],
      
  3. Performance Impact:

    • Risk: Ignition collects context data, which may slow down error pages in high-traffic apps.
    • Fix: Disable in production (Ignition is designed for development/staging):
      'enabled' => env('APP_ENV') !== 'production',
      
  4. Middleware Conflicts:

    • Risk: Some middlewares (e.g., CORS) may interfere with Ignition’s error handling.
    • Fix: Ensure Ignition’s middleware runs after your app’s middleware in app/Http/Kernel.php:
      protected $middleware = [
          // ...
          \Spatie\Ignition\Middleware\Ignition::class,
      ];
      
  5. Livewire 4+ Support:

    • Gotcha: Ignition v2.10+ drops Laravel 10/Livewire 2 support. Update if using newer versions:
      composer require laravel/livewire:"^4.0"
      

Debugging Tips

  1. Disable Ignition Temporarily:

    • Set IGNITION_ENABLED=false in .env to bypass Ignition for testing.
  2. Log Leakage:

    • If HTML view data leaks into laravel.log, ensure you’re using Ignition v1.7.1+ (fixed in #224).
  3. Custom Exception Handling:

    • To exclude certain exceptions from Ignition:
      Ignition::ignore(function (Throwable $e) {
          return $e instanceof CustomException;
      });
      
  4. Symfony 8/Laravel 13:

    • Ignition v2.12+ supports Symfony 8. If upgrading, check for deprecation warnings (e.g., Request::get()).
  5. AI Solutions:

    • Requires an OpenAI API key (OPENAI_API_KEY in .env). Disable with:
      'ai' => [
          'enabled' => false,
      ],
      

Extension Points

  1. Custom Context:

    • Add application-specific context to errors:
      use Spatie\Ignition\Context\Context;
      
      Context::capture(function () {
          return [
              'user_id' => auth()->id(),
              'custom_metric' => app()->get('custom.metric'),
          ];
      });
      
  2. Override Views:

    • Publish and modify Ignition’s Blade templates:
      php artisan vendor:publish --tag=ignition-views
      
    • Edit files in resources/views/vendor/ignition/.
  3. Solutions Providers:

    • Create reusable solution sets for your team:
      Solution::extend('laravel-shift', function () {
          return Solution::create('Laravel Shift')
              ->setDescription('Check Laravel Shift for migrations:')
              ->setSolution('https://laravel-shift.com');
      });
      
  4. Flare Middleware:

    • Extend Flare’s error reporting with custom data:
      use Spatie\FlareClient\Flare;
      
      Flare::extend(function ($report) {
          $report->addContext('custom', ['key' => 'value']);
      });
      
  5. Testing Ignition:

    • Use Ignition::fake() in tests to simulate errors without triggering the UI:
      $this->expectException(DivisionByZeroError::class);
      Ignition::fake();
      1 / 0;
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport