spatie/error-solutions
Collection of reusable “solutions” for common runtime errors, used by Spatie’s error tools like Ignition and Flare. Provides a shared way to suggest fixes and actionable hints when exceptions occur in Laravel and PHP apps.
Start by installing the package via Composer: composer require spatie/error-solutions. Once installed, no additional configuration is required — it hooks into Laravel’s exception handler automatically. The first use case is resolving common development errors, such as when a required config value is missing or a view expects a variable that wasn’t passed. Run php artisan error-solutions:check to scan your app for known issues and display actionable solutions directly in the CLI. For real-time feedback, trigger solutions in development via the provided resolve() helper or in your custom exception handler using Solutions::resolve($exception).
Use the built-in Solutions facade to programmatically suggest fixes during exception handling — for example, catch a MissingConfigValueException and offer to generate a stub .env entry. Extend the package by creating custom solution classes that implement Spatie\ErrorSolutions\Contracts\Solution and register them in config/error-solutions.php. Popular patterns include integrating solutions into report() or render() in App\Exceptions\Handler, and pairing with Laravel’s validateWithBag() or custom validation rules to auto-suggest field corrections. Leverage the SolutionsServiceProvider’s registerSolution() method to conditionally load context-aware solutions (e.g., only for local environments or specific exception types).
Solutions are suggestive — they don’t auto-fix code; ensure your app only calls resolve() in safe contexts (e.g., development or debug mode). The package’s solution lookup relies on matching exception types, not messages, so avoid catching generic exceptions before the solution resolver runs. If solutions don’t appear, verify APP_DEBUG=true, check that error-solutions.php config isn’t overriding the default solution path, and run config:clear after modifying config. Custom solutions should avoid heavy side effects — prefer prompting users to run commands (e.g., php artisan make:foo) or modify files via file_put_contents() rather than mutating DB directly. Lastly, all solutions are cached at runtime — clear storage/framework/cache if you update a solution class and don’t see changes.
How can I help you explore Laravel packages today?