ignaszak / error-handler
错误处理器
dev-master
2017-04-17 16:33 UTC
Requires
- php: >=7.0
- ignaszak/testing-tools: *
- kevinlebrun/colors.php: 0.*
- phpunit/phpunit: 6.*
This package is not auto-updated.
Last update: 2024-09-14 19:36:47 UTC
README
此包提供错误处理器接口
安装
"require" : {
"ignaszak/error-handler" : "dev-master"
}
要求
- PHP >= 7.0.0
- PHPUnit >= 6.0.0
使用方法
开发模式
<?php /** * Created by PhpStorm. * User: tomek * Date: 02.09.16 * Time: 14:45 */ declare(strict_types=1); use Ignaszak\ErrorHandler\Handler; use Ignaszak\ErrorHandler\View\Dev\DevView; include __DIR__ . '/vendor/autoload.php'; include 'included_file.php'; define('CONSTANT', 'demo'); // Start and register error handler with development interface $handler = Handler::start(new DevView()); $handler->register(); // Make some errors for test function test() { $func('test'); } test(); try { throw new Exception(); } catch (Exception $e) { $handler->catch($e); }
命令行模式
如果你在控制台运行你的应用程序,你可以使用CliView
。
<?php use Ignaszak\ErrorHandler\Handler; use Ignaszak\ErrorHandler\View\Cli\CliView; include __DIR__ . '/vendor/autoload.php'; $handler = Handler::start(new CliView()); $handler->register();