https://github.com/webrgp/craft-ignition
Ignition error handling alternative for Craft CMS
https://github.com/webrgp/craft-ignition
craftcms error-handling ignition php yii2-extension
Last synced: 10 months ago
JSON representation
Ignition error handling alternative for Craft CMS
- Host: GitHub
- URL: https://github.com/webrgp/craft-ignition
- Owner: webrgp
- License: mit
- Created: 2024-11-20T22:25:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-05T05:52:07.000Z (over 1 year ago)
- Last Synced: 2024-12-05T06:28:51.426Z (over 1 year ago)
- Topics: craftcms, error-handling, ignition, php, yii2-extension
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Ignition Error Handler for Craft CMS
Error handling alternative for Craft CMS that uses [Ignition](https://github.com/spatie/ignition) for better developer experience.

## Requirements
- Craft CMS 4.3.0 or higher
- PHP 8.0 or higher
## Installation
You can install the plugin via Composer:
```bash
composer require webrgp/craft-ignition
# OR if you only want to use it in development
composer require webrgp/craft-ignition --dev
```
This extension will bootstrap itself automatically once installed. Now you can enjoy Ignition's beautiful error pages in your Craft CMS project.
## Customizing Ignition
You can configure Ignition by adding the following settings to your `.env` file:
```env
CRAFT_IGNITION_EDITOR=vscode
CRAFT_IGNITION_THEME=light
CRAFT_IGNITION_REMOTE_SITES_PATH=/var/www/html
CRAFT_IGNITION_LOCAL_SITES_PATH=/Users/yourusername/Code/YourProject
CRAFT_IGNITION_SHARE_ENDPOINT=https://flareapp.io/api/public-reports
CRAFT_IGNITION_ENABLE_SHARE_BUTTON=true
CRAFT_IGNITION_ENABLE_RUNNABLE_SOLUTIONS=true
CRAFT_IGNITION_HIDE_SOLUTIONS=false
```
## How It Works
This package introduces the `IgnitionErrorHandler` class, which extends Craft's default `ErrorHandler` class. It overrides the `$exceptionView` property to use this package's custom exception view file, which renders Ignition's error page.
## Flare Middleware
This package also includes a few middleware classes that add Craft specific data to the Ignition error report and prevent Ignition from sharing sensitive information with Flare:
### AddCraftInfo middleware
This middleware Application Info, Plugins, and Modules information present in Craft's System Report to the Ignition's and Flare's error report.
### CraftSensitiveKeywords middleware
This middleware prevents Ignition from sharing sensitive information with Flare. It removes sensitive information from the error report before sharing it with Flare by testing each body parameter against Craft Security's [isSensitive](https://github.com/craftcms/cms/blob/2b2de25bfac0e359bcae62e0e6995bfdb4229eaa/src/services/Security.php#L176-L178) method.
You can customize the sensitive keywords by overriding the `sensitiveKeywords` in the Security component of the Craft app config:
```php
return [
'components' => [
'security' => [
'class' => \craft\services\Security::class,
'sensitiveKeywords' => [
'lorem',
],
],
]
];
```
[These are the default sensitive keywords](https://github.com/craftcms/cms/blob/2b2de25bfac0e359bcae62e0e6995bfdb4229eaa/src/config/app.php#L112-L121) in Craft CMS.
### Censored Headers middleware
Besides the sensitive keywords, this module also censors the following headers from the error report:
- `API-KEY`
- `Authorization`
- `Cookie`
- `Set-Cookie`
- `X-CSRF-TOKEN`
- `X-XSRF-TOKEN`
- `ip`
- `x-forwarded-for`
- `x-real-ip`
- `x-request-ip`
- `x-client-ip`
- `cf-connecting-ip`
- `fastly-client-ip`
- `true-client-ip`
- `forwarded`
- `proxy-client-ip`
- `wl-proxy-client-ip`
## Roadmap
- [ ] Add environment variable to disable Craft Ignition.
- [ ] Add Craft-specific solutions to Ignition.
## Acknowledgements
Thanks to [Andrew Welch](https://github.com/khalwat) for sharing his [nystudio107/plugindev](https://github.com/nystudio107/plugindev) with me!
## License
This plugin is open-sourced software licensed under the MIT license.