- Is symfony/error-handler already installed in Laravel?
- Yes. laravel/framework lists symfony/error-handler as a direct requirement alongside symfony/console, symfony/http-foundation, and symfony/http-kernel, so it is almost certainly already in your vendor tree. Run composer why symfony/error-handler to confirm the resolved version before adding anything explicitly. The decision is usually about using APIs you already ship, not adding a new dependency.
- How do I install symfony/error-handler in a Laravel project?
- In most apps you do not need to install it separately because Laravel already requires it. If you want an explicit entry, run composer require symfony/error-handler and let Composer resolve a version compatible with your laravel/framework pin. Avoid requiring the latest Symfony major, since that can conflict with Laravel's own constraint.
- Which Laravel and PHP versions support symfony/error-handler?
- Support follows the version Laravel pins rather than a separate Laravel compatibility matrix. Symfony 7 requires PHP 8.2 or newer, while Symfony 8 requires PHP 8.4 or newer and is a shorter non-LTS branch. Anchor to your laravel/framework constraint and verify the resolved version with composer why before relying on newer features.
- Can I use ErrorHandler::call() in Laravel to turn warnings into exceptions?
- Yes, this is the lowest-risk integration point. ErrorHandler::call() wraps a closure and converts failures, including code suppressed with the @ operator, into exceptions you can catch and handle normally. It does not replace Laravel's global handlers and is useful for risky file, JSON, or third-party calls at specific call sites. Keep the wrapped scope small so normal Laravel exception reporting still applies.
- Why does Debug::enable() break Laravel's exception handler?
- Debug::enable() registers Symfony's error, exception, and shutdown handlers globally. Laravel's Illuminate\Foundation\Bootstrap\HandleExceptions already owns those handlers, so calling Debug::enable() afterwards replaces Laravel's handler chain and disables App\Exceptions\Handler reporting and rendering, dontReport, and Laravel's log context enrichment. Treat Debug::enable() as forbidden in Laravel application code and use Laravel's own debug configuration instead.
- Does symfony/error-handler work safely with Laravel Octane?
- It can, but only with care. Handler registration performed during worker bootstrap persists across requests in long-lived workers such as Swoole or RoadRunner, so a globally registered handler can bleed exception state between requests or tenants. Verify behavior under Octane before adopting anything beyond ErrorHandler::call(), and avoid registering Symfony handlers in the worker lifecycle.
- How do I use FlattenException with Laravel for structured logging?
- FlattenException::createFromThrowable() normalizes a throwable into a serializable structure with class, message, code, file, line, trace, and previous exceptions. In Laravel you can call it inside a custom report() path or a logging context processor to produce consistent payloads for Sentry, OpsGenie, or JSON logs. It is a data-shaping utility and does not register handlers, so it does not conflict with Laravel's exception pipeline.
- Will symfony/error-handler cause duplicate error reports in Sentry?
- It can if Symfony's exception handler and Laravel's report() both fire for the same failure. Duplicate alerts inflate incident volume without adding signal, especially when both paths forward to the same Sentry or OpsGenie integration. Avoid registering Symfony's handler globally, and scope usage to call-site utilities like ErrorHandler::call() or FlattenException so only one reporting path remains.
- Is symfony/error-handler safe to use in Laravel production?
- It is safe for narrow uses such as ErrorHandler::call() at risky call sites, FlattenException for log payloads, and static error-page generation where Laravel cannot render. It is not safe to call Debug::enable() or ErrorHandler::register() in a live Laravel path, because that can leak stack traces, query bindings, environment-derived config, and request arguments through HtmlErrorRenderer. The highest-severity risk is hijacking Laravel's handler chain, so guard it as a hard rule rather than a code-review convention.
- What are alternatives to symfony/error-handler in Laravel?
- Laravel's built-in exception handling through App\Exceptions\Handler and Illuminate\Foundation\Bootstrap\HandleExceptions is the primary alternative and should remain the owner of global handlers. For debug pages, Spatie Ignition or Laravel's own debug views cover local development. For structured payloads you can also shape throwables manually, but FlattenException is already available via Laravel's dependency and is often the simplest option.