phalcon / pretty-exceptions
此包已被弃用且不再维护。作者建议使用 https://docs.phalconphp.com/en/latest/reference/debug.html#debug-component 包。
Phalcon 的美丽异常插件
dev-master
2016-08-20 18:29 UTC
Requires
- php: ~5.3
This package is not auto-updated.
Last update: 2017-03-16 20:27:25 UTC
README
已弃用 请使用 Phalcon\Debug 替代: https://docs.phalconphp.com/en/latest/reference/debug.html#debug-component
Phalcon 是一个作为 C 扩展提供的 Web 框架,提供高性能和低资源消耗。
Pretty Exceptions 是一个用于以良好视觉方式显示异常/错误/警告/通知的实用工具。
此实用工具不打算在生产环境中使用。
此实用工具捕获未捕获的异常,请记得移除任何阻止该实用工具工作的 try/catch。
此存储库中的代码是用 PHP 编写的。
自动使用
使用此实用工具最简单的方法是包含其 'loader'
require '/path/to/pretty-exceptions/loader.php';
手动包含
或者您可以通过手动包含或通过自动加载器包含此实用工具
//Requiring the file require '/path/to/pretty-exceptions/Library.php'; //Or using an autoloader $loader = new Phalcon\Loader(); $loader->registerNamespaces(array( 'Phalcon\\Utils' => '/path/to/pretty-exceptions/Library/Phalcon/Utils/' )); $loader->register();
使用方法
监听异常
set_exception_handler(function($e) { $p = new \Phalcon\Utils\PrettyExceptions(); return $p->handle($e); });
监听用户错误/警告/通知
set_error_handler(function($errorCode, $errorMessage, $errorFile, $errorLine) { $p = new \Phalcon\Utils\PrettyExceptions(); return $p->handleError($errorCode, $errorMessage, $errorFile, $errorLine); });
选项
以下是配置实用工具的方式
$p = new \Phalcon\Utils\PrettyExceptions(); //Change the base uri for static resources $p->setBaseUri('/'); //Set if the backtrace must be shown $p->showBacktrace(true); //Set whether if open the user files and show its code $p->showFiles(true); //Set whether show the complete file or just the relevant fragment $p->showFileFragment(true); /** * Set whether show human readable dump of current Phalcon application instance * Can optionally pass a Phalcon application instance as a parameter in the * constructor, or as the last parameter of PrettyExceptions::handle() and * PrettyExceptions::handleError() */ $p->showApplicationDump(true); //Change the CSS theme (default, night or minimalist) $p->setTheme('default'); //Handle the error/exception //...