- How do I install sycho/errors in a Laravel application?
- Install the package with composer require sycho/errors. If your Laravel version does not auto-discover the service provider, register it manually in the providers configuration. Publish any package configuration or views with php artisan vendor:publish as described in the package docs.
- Which Laravel and PHP versions does sycho/errors support?
- The provided overview does not include a complete support matrix, so check the package composer.json for its declared php and illuminate/* constraints. Because it plugs into Laravel's native exception handler, verify compatibility with your current Laravel major and PHP version before adopting it.
- How does sycho/errors return JSON for API requests versus HTML for browsers?
- It detects the incoming request type and renders HTML error pages for browser requests or clean JSON payloads for API requests from the same exception mapping. That avoids sending HTML error pages to API clients while preserving friendly error pages for users.
- How do I map exception classes to status codes, views, and messages?
- Define mappings in the package configuration that associate exception classes with a status code, optional view, and message. The package uses those mappings inside Laravel's exception rendering pipeline, so you centralize the behavior instead of scattering try/catch blocks or custom handlers.
- Can I customize or publish the error page views?
- The package includes publishable, themeable views for common HTTP errors. Publish them with Laravel's vendor:publish command, then edit the templates to match your application's design and messaging.
- Does sycho/errors replace Laravel's default exception handler?
- It extends Laravel's native exception pipeline rather than replacing the framework's handler, and it plugs into the existing exception handler and service container. You still rely on Laravel's exception handling, while the package centralizes render and report behavior on top of it.
- How do I control which exceptions are reported or logged with sycho/errors?
- The package provides reporting hooks that let you decide which exceptions are logged and how they are reported. Use them to suppress noisy expected exceptions while keeping unexpected failures visible in your logs and monitoring tools.
- How should I test sycho/errors error responses in Laravel?
- Use Laravel's HTTP testing helpers to make requests that trigger known exceptions, then assert the response status, rendered view, or JSON structure. Cover both Accept: application/json and browser-style requests to confirm the package returns the correct unified output for each case.
- Is sycho/errors suitable for production, and how is it maintained?
- The package is small, MIT-licensed, and easy to audit or vendor, but the evaluation notes a single maintainer and no visible CI or release cadence. Treat it as a private utility and timebox a spike before placing it on the error path of every request.
- What are the alternatives to sycho/errors and can it conflict with Ignition or Sentry?
- Alternatives include Laravel's built-in renderable and reportable hooks, a small custom DomainException base plus Handler::renderable(), and observability SDKs such as Ignition, Sentry, or Flare. Because those tools hook the same exception paths, run a spike to check for overlapping render or report behavior before combining them.