2017 © Pedro Peláez
 

library excp-handler

image

penny/excp-handler

  • Sunday, September 25, 2016
  • by GianArb
  • Repository
  • 0 Watchers
  • 1 Stars
  • 79 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

Exception Handler

Build Status
This project helps you to manage your exceptions with whoops., (*1)

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., (*2)

Project

This project constains a Penny event listener ready to use in your penny application., (*3)

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:, (*4)

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

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

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., (*6)

The Versions