penny/excp-handler

This package is abandoned and no longer maintained. No replacement package was suggested.

0.0.2 2016-01-30 18:08 UTC

This package is not auto-updated.

Last update: 2021-03-15 09:16:20 UTC


README

Build Status
This project helps you to manage your exceptions with whoops.

Whoops

whoops is an error handler base/framework for PHP. Out-of-the-box, it provides a pretty error interface that helps you debug your web projects, but at heart it's a simple yet powerful stacked error handling system.

Project

This project constains a Penny event listener ready to use in your penny application.

Install

composer require penny/excp-handler

Getting Started

The Penny Event Listener provided is a Penny\ExcpHandler\EventListener\WhoopsListener, which contains method onError($e) that can pass event that is a EventInterface implementation. You can set up whoops handlers by provide $current and $handlers parameter in contructor:

public function __construct($current = "html", $handlers = [])

You may use default implementation by leave them as empty when create a Penny\ExcpHandler\EventListener\WhoopsListener instance.

Usage in Penny Skeleton Application

  • composer require as above
  • register in config/di.php:
use Penny\ExcpHandler\EventListener\WhoopsListener;

return [
    'event_manager' => \DI\decorate(function($eventManager, $container) {
        $eventManager->attach("dispatch_error", [$container->get(WhoopsListener::class), "onError"]);
        // you may need to apply to '*_error' as well...
        
        // other event here...
        return $eventManager;
    }),
    
    WhoopsListener::class => \DI\object(WhoopsListener::class),

That's it. And you're ready to go.