whoops is a PHP error-handler library with a stacked handler model. It ships a detailed HTML error page for web apps plus JSON, XML, and plain-text handlers.
Overview
whoops is an error-handling framework for PHP projects. At its core it provides flexible, stack-based processing of exceptions and errors, with a simple API for trace frames and attached data.
The default PrettyPageHandler renders a structured HTML error page for web applications, including stack frames with highlighted source lines and hooks to open referenced files in an editor or IDE. Handlers can add tables and request-specific context through middleware-style extensions.
Additional built-in handlers cover CLI plain text output, JSON for AJAX clients, XML responses, SOAP-oriented flows, and wrapping callables as handlers. Projects can push handlers onto the stack so the first matching handler controls the response format.
The package is a stand-alone library with no required dependencies in the documentation. It integrates with several PHP frameworks and middleware stacks, and can be registered manually when frameworks are not used.
Key features
- Stack-based handler pipeline
- Pretty HTML error pages
- Stack trace code highlighting
- Editor and IDE file links
- JsonResponseHandler for AJAX
- XmlResponseHandler
- PlainTextHandler for CLI
- Extensible custom handlers
Use cases
- PHP web app debugging
- AJAX error JSON responses
- CLI exception output
- Framework error integration