gitmyhub

whoops

PHP ★ 13k updated 1mo ago

PHP errors for cool kids

A PHP error handling library that replaces the default confusing crash screen with a clear, well-designed error page showing exactly what went wrong and where in your code.

PHPComposersetup: easycomplexity 2/5

whoops is a library for PHP, a programming language used to build websites and web applications, that improves how errors are shown when something goes wrong in your code. Its tagline calls it PHP errors for cool kids. Out of the box, when your program crashes, whoops replaces the usual confusing error message with a clear, well-designed error page that helps a developer see what happened and where.

Underneath the friendly error page, the README describes it as a stacked error handling system. In plain terms, you can register one or more handlers that each get a chance to deal with an error, and you can arrange them in order. The library has no required outside dependencies and offers a simple way to inspect an exception and the chain of function calls that led to it. One handy feature noted in the README is the ability to click a referenced file in the error page and open it directly in your code editor.

whoops ships with several built-in handlers for different situations. The PrettyPageHandler produces the polished error page, the PlainTextHandler is meant for command-line programs, and the JsonResponseHandler and XmlResponseHandler return error details in formats that work well with background web requests. A callback handler lets you plug in your own custom logic.

Installation is straightforward. The README notes that several popular PHP frameworks, including recent versions of Laravel, already include whoops, and it lists community guides for many others. If you are not using one of those, you can add it with Composer, the standard PHP package manager, and register the pretty handler in a few lines of code. The README also shows how to capture the generated error HTML yourself instead of displaying it directly. The library was created by Filipe Dobreira and is currently maintained by Denis Sokolov, with help from many contributors.

Where it fits