{"id":19324829,"url":"https://github.com/spatie/ignition","last_synced_at":"2025-05-13T23:06:21.024Z","repository":{"id":37013462,"uuid":"369442367","full_name":"spatie/ignition","owner":"spatie","description":"A beautiful error page for PHP apps","archived":false,"fork":false,"pushed_at":"2025-05-12T10:19:03.000Z","size":13527,"stargazers_count":474,"open_issues_count":22,"forks_count":56,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-12T11:31:56.168Z","etag":null,"topics":["debug","error","page","php"],"latest_commit_sha":null,"homepage":"https://flareapp.io/ignition","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"spatie"}},"created_at":"2021-05-21T06:56:09.000Z","updated_at":"2025-05-12T10:19:00.000Z","dependencies_parsed_at":"2024-11-24T04:00:56.926Z","dependency_job_id":"a664ed8c-34e6-47eb-a05f-99ed594b9a14","html_url":"https://github.com/spatie/ignition","commit_stats":{"total_commits":501,"total_committers":37,"mean_commits":13.54054054054054,"dds":0.6586826347305389,"last_synced_commit":"9c36a31011a304bc4e490f8fafb157b62f431391"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":"spatie/package-skeleton-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fignition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fignition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fignition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fignition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/ignition/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036831,"owners_count":22003654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debug","error","page","php"],"created_at":"2024-11-10T02:06:58.297Z","updated_at":"2025-05-13T23:06:16.009Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":[],"sub_categories":[],"readme":"# Ignition: a beautiful error page for PHP apps\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/ignition.svg?style=flat-square)](https://packagist.org/packages/spatie/ignition)\n[![Run tests](https://github.com/spatie/ignition/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/ignition/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/ignition.svg?style=flat-square)](https://packagist.org/packages/spatie/ignition)\n\n[Ignition](https://flareapp.io/docs/ignition-for-laravel/introduction) is a beautiful and customizable error page for\nPHP applications\n\nHere's a minimal example on how to register ignition.\n\n```php\nuse Spatie\\Ignition\\Ignition;\n\ninclude 'vendor/autoload.php';\n\nIgnition::make()-\u003eregister();\n```\n\nLet's now throw an exception during a web request.\n\n```php\nthrow new Exception('Bye world');\n```\n\nThis is what you'll see in the browser.\n\n![Screenshot of ignition](https://spatie.github.io/ignition/ignition.png)\n\nThere's also a beautiful dark mode.\n\n![Screenshot of ignition in dark mode](https://spatie.github.io/ignition/ignition-dark.png)\n\n## Are you a visual learner?\n\nIn [this video on YouTube](https://youtu.be/LEY0N0Bteew?t=739), you'll see a demo of all of the features.\n\nDo know more about the design decisions we made, read [this blog post](https://freek.dev/2168-ignition-the-most-beautiful-error-page-for-laravel-and-php-got-a-major-redesign).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/ignition.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/ignition)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can\nsupport us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.\nYou'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards\non [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nFor Laravel apps, head over to [laravel-ignition](https://github.com/spatie/laravel-ignition).\n\nFor Symfony apps, go to [symfony-ignition-bundle](https://github.com/spatie/symfony-ignition-bundle).\n\nFor Drupal 10+ websites, use the [Ignition module](https://www.drupal.org/project/ignition).\n\nFor OpenMage websites, use the [Ignition module](https://github.com/empiricompany/openmage_ignition).\n\nFor all other PHP projects, install the package via composer:\n\n```bash\ncomposer require spatie/ignition\n```\n\n## Usage\n\nIn order to display the Ignition error page when an error occurs in your project, you must add this code. Typically, this would be done in the bootstrap part of your application.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()-\u003eregister();\n```\n\n### Setting the application path\n\nWhen setting the application path, Ignition will trim the given value from all paths. This will make the error page look\nmore cleaner.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003eapplicationPath($basePathOfYourApplication)\n    -\u003eregister();\n```\n\n### Using dark mode\n\nBy default, Ignition uses a nice white based theme. If this is too bright for your eyes, you can use dark mode.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003esetTheme('dark')\n    -\u003eregister();\n```\n\n### Avoid rendering Ignition in a production environment\n\nYou don't want to render the Ignition error page in a production environment, as it potentially can display sensitive\ninformation.\n\nTo avoid rendering Ignition, you can call `shouldDisplayException` and pass it a falsy value.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003eshouldDisplayException($inLocalEnvironment)\n    -\u003eregister();\n```\n\n### Displaying solutions\n\nIn addition to displaying an exception, Ignition can display a solution as well.\n\nOut of the box, Ignition will display solutions for common errors such as bad methods calls, or using undefined properties.\n\n#### Adding a solution directly to an exception\n\nTo add a solution text to your exception, let the exception implement the `Spatie\\Ignition\\Contracts\\ProvidesSolution`\ninterface.\n\nThis interface requires you to implement one method, which is going to return the `Solution` that users will see when\nthe exception gets thrown.\n\n```php\nuse Spatie\\Ignition\\Contracts\\Solution;\nuse Spatie\\Ignition\\Contracts\\ProvidesSolution;\n\nclass CustomException extends Exception implements ProvidesSolution\n{\n    public function getSolution(): Solution\n    {\n        return new CustomSolution();\n    }\n}\n```\n\n```php\nuse Spatie\\Ignition\\Contracts\\Solution;\n\nclass CustomSolution implements Solution\n{\n    public function getSolutionTitle(): string\n    {\n        return 'The solution title goes here';\n    }\n\n    public function getSolutionDescription(): string\n    {\n        return 'This is a longer description of the solution that you want to show.';\n    }\n\n    public function getDocumentationLinks(): array\n    {\n        return [\n            'Your documentation' =\u003e 'https://your-project.com/relevant-docs-page',\n        ];\n    }\n}\n```\n\nThis is how the exception would be displayed if you were to throw it.\n\n![Screenshot of solution](https://spatie.github.io/ignition/solution.png)\n\n#### Using solution providers\n\nInstead of adding solutions to exceptions directly, you can also create a solution provider. While exceptions that\nreturn a solution, provide the solution directly to Ignition, a solution provider allows you to figure out if an\nexception can be solved.\n\nFor example, you could create a custom \"Stack Overflow solution provider\", that will look up if a solution can be found\nfor a given throwable.\n\nSolution providers can be added by third party packages or within your own application.\n\nA solution provider is any class that implements the \\Spatie\\Ignition\\Contracts\\HasSolutionsForThrowable interface.\n\nThis is how the interface looks like:\n\n```php\ninterface HasSolutionsForThrowable\n{\n    public function canSolve(Throwable $throwable): bool;\n\n    /** @return \\Spatie\\Ignition\\Contracts\\Solution[] */\n    public function getSolutions(Throwable $throwable): array;\n}\n```\n\nWhen an error occurs in your app, the class will receive the `Throwable` in the `canSolve` method. In that method you\ncan decide if your solution provider is applicable to the `Throwable` passed. If you return `true`, `getSolutions` will\nget called.\n\nTo register a solution provider to Ignition you must call the `addSolutionProviders` method.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003eaddSolutionProviders([\n        YourSolutionProvider::class,\n        AnotherSolutionProvider::class,\n    ])\n    -\u003eregister();\n```\n\n### AI powered solutions\n\nIgnition can send your exception to Open AI that will attempt to automatically suggest a solution. In many cases, the suggested solutions is quite useful, but keep in mind that the solution may not be 100% correct for your context.\n\nTo generate AI powered solutions, you must first install this optional dependency.\n\n```bash\ncomposer require openai-php/client\n```\n\nTo start sending your errors to OpenAI, you must instanciate the `OpenAiSolutionProvider`. The constructor expects a OpenAI API key to be passed, you should generate this key [at OpenAI](https://platform.openai.com).\n\n```php\nuse \\Spatie\\Ignition\\Solutions\\OpenAi\\OpenAiSolutionProvider;\n\n$aiSolutionProvider = new OpenAiSolutionProvider($openAiKey);\n```\n\nTo use the solution provider, you should pass it to `addSolutionProviders` when registering Ignition.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003eaddSolutionProviders([\n        $aiSolutionProvider,\n        // other solution providers...\n    ])\n    -\u003eregister();\n```\n\nBy default, the solution provider will send these bits of info to Open AI:\n\n- the error message\n- the error class\n- the stack frame\n- other small bits of info of context surrounding your error\n\nIt will not send the request payload or any environment variables to avoid sending sensitive data to OpenAI.\n\n#### Caching requests to AI\n\nBy default, all errors will be sent to OpenAI. Optionally, you can add caching so similar errors will only get sent to OpenAI once. To cache errors, you can call `useCache` on `$aiSolutionProvider`. You should pass [a simple-cache-implementation](https://packagist.org/providers/psr/simple-cache-implementation). Here's the signature of the `useCache` method.\n\n```php\npublic function useCache(CacheInterface $cache, int $cacheTtlInSeconds = 60 * 60)\n```\n\n#### Hinting the application type\n\nTo increase the quality of the suggested solutions, you can send along the application type (Symfony, Drupal, WordPress, ...) to the AI. \n\nTo send the application type call `applicationType` on the solution provider.\n\n```php\n$aiSolutionProvider-\u003eapplicationType('WordPress 6.2')\n```\n\n### Sending exceptions to Flare\n\nIgnition comes with the ability to send exceptions to [Flare](https://flareapp.io), an exception monitoring service. Flare\ncan notify you when new exceptions are occurring in your production environment.\n\nTo send exceptions to Flare, simply call the `sendToFlareMethod` and pass it the API key you got when creating a project\non Flare.\n\nYou probably want to combine this with calling `runningInProductionEnvironment`. That method will, when passed a truthy\nvalue, not display the Ignition error page, but only send the exception to Flare.\n\n```php\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003erunningInProductionEnvironment($boolean)\n    -\u003esendToFlare($yourApiKey)\n    -\u003eregister();\n```\n\nWhen you pass a falsy value to `runningInProductionEnvironment`, the Ignition error page will get shown, but no\nexceptions will be sent to Flare.\n\n### Sending custom context to Flare\n\nWhen you send an error to Flare, you can add custom information that will be sent along with every exception that\nhappens in your application. This can be very useful if you want to provide key-value related information that\nfurthermore helps you to debug a possible exception.\n\n```php\nuse Spatie\\FlareClient\\Flare;\n\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003erunningInProductionEnvironment($boolean)\n    -\u003esendToFlare($yourApiKey)\n    -\u003econfigureFlare(function(Flare  $flare) {\n        $flare-\u003econtext('Tenant', 'My-Tenant-Identifier');\n    })\n    -\u003eregister();\n```\n\nSometimes you may want to group your context items by a key that you provide to have an easier visual differentiation\nwhen you look at your custom context items.\n\nThe Flare client allows you to also provide your own custom context groups like this:\n\n```php\nuse Spatie\\FlareClient\\Flare;\n\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003erunningInProductionEnvironment($boolean)\n    -\u003esendToFlare($yourApiKey)\n    -\u003econfigureFlare(function(Flare  $flare) {\n        $flare-\u003egroup('Custom information', [\n            'key' =\u003e 'value',\n            'another key' =\u003e 'another value',\n        ]);\n    })\n    -\u003eregister();\n```\n\n### Anonymize request to Flare\n\nBy default, the Ignition collects information about the IP address of your application users. If you don't want to send this information to Flare, call `anonymizeIp()`.\n\n```php\nuse Spatie\\FlareClient\\Flare;\n\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003erunningInProductionEnvironment($boolean)\n    -\u003esendToFlare($yourApiKey)\n    -\u003econfigureFlare(function(Flare  $flare) {\n        $flare-\u003eanonymizeIp();\n    })\n    -\u003eregister();\n```\n\n### Censoring request body fields\n\nWhen an exception occurs in a web request, the Flare client will pass on any request fields that are present in the body.\n\nIn some cases, such as a login page, these request fields may contain a password that you don't want to send to Flare.\n\nTo censor out values of certain fields, you can use `censorRequestBodyFields`. You should pass it the names of the fields you wish to censor.\n\n```php\nuse Spatie\\FlareClient\\Flare;\n\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003erunningInProductionEnvironment($boolean)\n    -\u003esendToFlare($yourApiKey)\n    -\u003econfigureFlare(function(Flare  $flare) {\n        $flare-\u003ecensorRequestBodyFields(['password']);\n    })\n    -\u003eregister();\n```\n\nThis will replace the value of any sent fields named \"password\" with the value \"\u003cCENSORED\u003e\".\n\n### Using middleware to modify data sent to Flare\n\nBefore Flare receives the data that was collected from your local exception, we give you the ability to call custom middleware methods. These methods retrieve the report that should be sent to Flare and allow you to add custom information to that report.\n\nA valid middleware is any class that implements `FlareMiddleware`.\n\n```php\nuse Spatie\\FlareClient\\Report;\n\nuse Spatie\\FlareClient\\FlareMiddleware\\FlareMiddleware;\n\nclass MyMiddleware implements FlareMiddleware\n{\n    public function handle(Report $report, Closure $next)\n    {\n        $report-\u003emessage(\"{$report-\u003egetMessage()}, now modified\");\n\n        return $next($report);\n    }\n}\n```\n\n```php\nuse Spatie\\FlareClient\\Flare;\n\n\\Spatie\\Ignition\\Ignition::make()\n    -\u003erunningInProductionEnvironment($boolean)\n    -\u003esendToFlare($yourApiKey)\n    -\u003econfigureFlare(function(Flare  $flare) {\n        $flare-\u003eregisterMiddleware([\n            MyMiddleware::class,\n        ])\n    })\n    -\u003eregister();\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Dev setup\n\nHere are the steps you'll need to perform if you want to work on the UI of Ignition.\n\n- clone (or move) `spatie/ignition`, `spatie/ignition-ui`, `spatie/laravel-ignition`, `spatie/flare-client-php` and `spatie/ignition-test` into the same directory (e.g. `~/code/flare`)\n- create a new `package.json` file in `~/code/flare` directory:\n```json\n{\n    \"private\": true,\n    \"workspaces\": [\n        \"ignition-ui\",\n        \"ignition\"\n    ]\n}\n```\n- run `yarn install` in the `~/code/flare` directory\n- in the `~/code/flare/ignition-test` directory\n    - run `composer update`\n    - run `cp .env.example .env`\n    - run `php artisan key:generate`\n- run `yarn dev` in both the `ignition` and `ignition-ui` project\n- http://ignition-test.test/ should now work (= show the new UI). If you use valet, you might want to run `valet park` inside the `~/code/flare` directory.\n    - http://ignition-test.test/ has a bit of everything\n    - http://ignition-test.test/sql-error has a solution and SQL exception\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Spatie](https://spatie.be)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fignition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fignition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fignition/lists"}