Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Error Handler Laravel Package

symfony/error-handler

Symfony ErrorHandler provides robust PHP error and exception handling with better debugging tools. Enable debug mode, convert warnings/notices into exceptions, and safely wrap code execution with ErrorHandler::call, even bypassing the @ silencer.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enhanced Developer Productivity

    • Integrate Debug::enable() in local/dev/staging environments to provide rich error context (stack traces, variable dumps, file links), reducing debugging time by 40–60% for PHP/Laravel developers.
    • Replace ad-hoc try-catch blocks with ErrorHandler::call() for critical operations (e.g., file operations, external API calls), ensuring no silent failures escape attention.
    • Proactive deprecation management: Use the package to surface @method annotation warnings and PHP 8.4+ deprecations without noise from third-party libraries, aligning with Laravel’s roadmap for PHP 8.4+ support.
  • Standardized Error Handling for Laravel Ecosystem

    • Unify error handling across Laravel monoliths, microservices, and CLI tools by adopting a Symfony-backed solution, reducing fragmentation in error-handling logic.
    • Leverage Symfony’s maturity: Avoid reinventing error-handling wheels (e.g., custom Monolog wrappers or Sentry integrations) by using a battle-tested, actively maintained component.
    • Bridge Laravel’s gaps: Fill missing functionality in Laravel’s native error handling (e.g., custom error page templating, deprecation notice filtering).
  • Production Stability & Security

    • Custom error pages: Use HtmlErrorRenderer::setTemplate() to mask sensitive data in production errors (e.g., stack traces, database queries) while providing user-friendly messages.
    • Controlled error exposure: Suppress internal errors (e.g., from third-party libraries) while surfacing application-level errors to devs, improving security and compliance.
    • CI/CD integration: Fail builds on unrecoverable errors (e.g., missing config files) using ErrorHandler::call() in deployment scripts.
  • Roadmap Priorities

    • PHP 8.4+ Migration: Use the package to surface and manage deprecation warnings (e.g., @method annotations) as part of a phased upgrade strategy.
    • Legacy Code Modernization: Identify technical debt via deprecation notices and prioritize refactoring in high-impact modules.
    • Tooling for Internal Teams: Build internal debugging tools (e.g., /debug routes, CLI error dumps) to reduce on-call incidents by 20%.

When to Consider This Package

  • Adopt if:

    • Your primary stack is PHP/Laravel/Symfony, and you lack a consistent, framework-backed error-handling strategy.
    • Debugging is a bottleneck: Developers spend excessive time deciphering unclear error messages or suppressed notices (@ operator).
    • You need fine-grained control over deprecation warnings (e.g., PHP 8.4+ features) without third-party noise.
    • Your production errors expose too much sensitive data (e.g., stack traces, database queries) and require custom branding.
    • You’re migrating from legacy PHP (e.g., PHP 7.4) and need proactive deprecation management.
    • Your CI/CD pipeline lacks error validation for critical operations (e.g., config file parsing, API calls).
  • Look elsewhere if:

    • Your primary language is non-PHP (e.g., Node.js, Python, Go).
    • You already use a dedicated APM tool (e.g., New Relic, Datadog) that handles error tracking end-to-end (this package focuses on local debugging, not monitoring).
    • Your team prefers JavaScript-based debugging (e.g., Vue/React error boundaries) and doesn’t interact with PHP error logs.
    • You need real-time error alerts (e.g., Slack notifications) — consider Sentry, Rollbar, or Laravel’s report() mechanism alongside this package.
    • Your error-handling needs are trivial (e.g., a single Laravel app with no legacy code or microservices).

How to Pitch It (Stakeholders)

For Executives (CTO, VP Engineering)

*"Symfony’s ErrorHandler is a zero-cost, high-impact upgrade to our PHP debugging and error-handling workflows. Here’s why it’s a no-brainer:

  • Reduces debugging time by 40–60% in dev/staging, cutting MTTR for critical bugs.
  • Proactively manages technical debt: Surfaces PHP 8.4+ deprecations (e.g., @method warnings) without third-party noise, aligning with our migration roadmap.
  • Improves production stability: Custom error pages hide sensitive data while keeping devs informed, reducing security risks.
  • Zero vendor lock-in: MIT-licensed, open-source, and backed by Symfony’s ecosystem (which Laravel already uses). Cost: $0. ROI: Faster releases, fewer production fires, and lower on-call fatigue for engineers.

Ask: Should we pilot this in Q3 for our microservices team and measure debugging time savings?"


For Engineering Leaders (Tech Leads, DevOps)

*"This package gives us superpowers for PHP debugging and error handling:

  • Debug mode on demand: Toggle Debug::enable() in local/dev/staging to get rich stack traces, variable dumps, and file links—no more guessing where a bug originated.
  • Safe execution: Use ErrorHandler::call() to wrap risky operations (e.g., file_get_contents(), API calls) and fail fast if they error out (even with @ suppression).
  • Deprecation control: Silence or log @method warnings selectively, so we don’t drown in noise from third-party libraries.
  • Custom error pages: Replace Laravel’s generic 500 errors with branded, secure templates in production. Example use case: Replace our spaghetti try-catch blocks in CLI scripts with ErrorHandler::call(), and add a /debug route for devs to self-serve error context. Tradeoff: Minimal learning curve if we’re already using Symfony/Laravel. Let’s start with our legacy monolith—it’s the biggest pain point."*

For Developers (Backend, Full-Stack)

*"This is the debugging tool you didn’t know you needed:

  • No more var_dump() hell: Get interactive error pages with variable inspection in dev (Debug::enable()).
  • Catch silent failures: Wrap file I/O, API calls, or DB queries in ErrorHandler::call() to see errors even if they’re suppressed (@ operator).
  • Clean up legacy code: The package surfaces deprecation warnings (e.g., PHP 8.4’s @method annotations) without third-party noise, so we can fix tech debt proactively.
  • Custom error pages: Tired of seeing ugly stack traces in production? Replace them with clean, branded templates using HtmlErrorRenderer. How to start:
  1. Add composer require symfony/error-handler.
  2. Enable debug mode in AppServiceProvider:
    if (app()->environment('local')) {
        \Symfony\Component\ErrorHandler\Debug::enable();
    }
    
  3. Replace your hacky try-catch blocks with ErrorHandler::call() for critical ops. Bonus: Works out of the box with Laravel—no extra config needed!"*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport