whoops

whoops is a nice little library that helps you develop and maintain your projects better, by helping you deal with errors and exceptions in a less painful way.

Features

  • Includes providers for Silex and Zend Framework 2, with community-provided support for other platforms and frameworks
  • Now included in the Laravel 4 core!
  • Detailed & intuitive page for errors and exceptions (PrettyPageHandler)
  • Code view for all frames in a stack trace with line highlights (PrettyPageHandler)
  • Frame comments & analysis through custom middle-ware/handlers (PrettyPageHandler)
  • Request & app-specific information through custom middle-ware/handlers (PrettyPageHandler)
  • JSON & AJAX support (JsonResponseHandler)
  • XML & SOAP support (XmlResponsehandler, SoapResponseHandler)
  • Clean and tested code-base that’s easy to extend and build on to make it work just right for your project

Download

With Composer:

{ "require": { "filp/whoops": "2.*" } }
$ cd my_project $ composer install

Use

In your Silex project, register the bundled Service Provider:

$app->register(new Whoops\Provider\Silex\WhoopsServiceProvider);

For integration instructions with other frameworks or platforms, check out the README file.

Or if you’d rather take control, integrate it manually and tweak it to fit your needs:

require __DIR__ . "/vendor/autoload.php"; use Whoops\Handler\PrettyPageHandler; use Whoops\Handler\JsonResponseHandler; $run = new Whoops\Run; $handler = new PrettyPageHandler; // Add some custom tables with relevant info about your application, // that could prove useful in the error page: $handler->addDataTable('Killer App Details', array( "Important Data" => $myApp->getImportantData(), "Thingamajig-id" => $someId )); // Set the title of the error page: $handler->setPageTitle("Whoops! There was a problem."); $run->pushHandler($handler); // Add a special handler to deal with AJAX requests with an // equally-informative JSON response. Since this handler is // first in the stack, it will be executed before the error // page handler, and will have a chance to decide if anything // needs to be done. if (Whoops\Util\Misc::isAjaxRequest()) { $run->pushHandler(new JsonResponseHandler); } // Register the handler with PHP, and you're set! $run->register();

Originally published at www.laravelfeed.com.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.