penny / excp-handler
此包已 弃用 且不再维护。未建议替代包。
0.0.2
2016-01-30 18:08 UTC
Requires
- filp/whoops: ^1.0
- gianarb/penny: dev-master
- squizlabs/php_codesniffer: ~2.5
Requires (Dev)
- phpunit/phpunit: ^5.0
This package is not auto-updated.
Last update: 2021-03-15 09:16:20 UTC
README
此项目帮助您使用 whoops 管理异常。
Whoops
Whoops 是一个 PHP 的错误处理基础框架。它自带一个美观的错误界面,帮助您调试 Web 项目,但本质上它是一个简单而强大的错误处理系统。
项目
本项目包含一个可用于 penny 应用的 Penny 事件监听器。
安装
composer require penny/excp-handler
入门
提供的 Penny Event Listener 是一个 Penny\ExcpHandler\EventListener\WhoopsListener
,其中包含 onError($e)
方法,可以传递实现 EventInterface
接口的事件。您可以通过在构造函数中提供 $current
和 $handlers
参数来设置 whoops 处理程序。
public function __construct($current = "html", $handlers = [])
您可以通过在创建 Penny\ExcpHandler\EventListener\WhoopsListener
实例时将其留空来使用默认实现。
Penny 框架应用程序中的使用
- 按照 上面 的说明使用 composer 安装
- 在
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),
就是这样。现在您可以开始了。