whoops README

The project's README from github.com/filp/whoops. As one markdown file: README.md.

whoops

PHP errors for cool kids

Total Downloads Latest Version Build Status on newer versions Scrutinizer Quality Score Code Coverage


Whoops!

whoops is an error handler 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.

Features

Sponsors

Blackfire.io Oblak Host

Installing

If you use Laravel 4, Laravel 5.5+, Mezzio or ZubZet 1.2+, you already have Whoops. There are also community-provided instructions on how to integrate Whoops into Silex 1, Silex 2, Phalcon, Laravel 3, Laravel 5, CakePHP 3, CakePHP 4, Zend 2, Zend 3, Yii 1, FuelPHP, Slim, Pimple, Laminas, or any framework consuming StackPHP middlewares or PSR-7 middlewares.

If you are not using any of these frameworks, here's a very simple way to install:

  1. Use Composer to install Whoops into your project:

    composer require filp/whoops
    
  2. Register the pretty handler in your code:

    $whoops = new \Whoops\Run;
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
    $whoops->register();
    

For more options, have a look at the example files in examples/ to get a feel for how things work. Also take a look at the API Documentation and the list of available handlers below.

You may also want to override some system calls Whoops does. To do that, extend Whoops\Util\SystemFacade, override functions that you want and pass it as the argument to the Run constructor.

You may also collect the HTML generated to process it yourself:

$whoops = new \Whoops\Run;
$whoops->allowQuit(false);
$whoops->writeToOutput(false);
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$html = $whoops->handleException($e);

Available Handlers

whoops currently ships with the following built-in handlers, available in the Whoops\Handler namespace:

You can also use pluggable handlers, such as SOAP handler.

Authors

This library was primarily developed by Filipe Dobreira, and is currently maintained by Denis Sokolov. A lot of awesome fixes and enhancements were also sent in by various contributors. Special thanks to Graham Campbell and Markus Staab for continuous participation.

whoops (filp/whoops)

Searching Database…

13.2K ·GitHub
这是什么东西?whoops 是一个 PHP 的错误处理框架:当你的网页项目出问题时,它会显示一个美观的错误页面,而不是原始的堆栈跟踪。它基于可堆叠的错误处理机制构建。
它是添加到我项目里的库,还是可以单独运行的工具?是一个库:它自称错误处理框架,但你需要把它安装到自己的 PHP 项目里,并在自己的代码中注册处理器——它不是一个独立的应用或服务。
我怎么把它跑起来?用 Composer 安装,然后在代码中注册美观页面处理器。如果你用的是 Laravel 4、Laravel 5.5+、Mezzio 或 ZubZet 1.2+,它已经内置了,不需要再安装。
它会给我的项目引入一堆依赖吗?不会——whoops 是一个独立库,没有任何必需的依赖,而且它的设计目标就是易于扩展,方便和现有的库集成。
如果错误发生在 AJAX 请求或 CLI 脚本里怎么办?它自带针对不同响应格式的处理器:JsonResponseHandler 和 XmlResponseHandler 会把异常信息以 JSON 或 XML 格式返回给 AJAX 请求,PlainTextHandler 则为命令行应用输出纯文本。
我需要自己把它接入框架吗?不一定:Laravel 4、Laravel 5.5+、Mezzio 和 ZubZet 1.2+ 已经内置了它,另外 Silex、Phalcon、CakePHP、Zend、Yii、Slim、Laminas,以及所有基于 StackPHP 或 PSR-7 中间件的东西,都有社区提供的使用指南。
我可以添加自己的错误处理器吗?可以——处理器是可堆叠的:把你自己的闭包或可调用对象压入堆栈,whoops 会自动包装它。你还可以通过继承 SystemFacade 类来覆盖系统调用,或者收集生成的 HTML 自己做后续处理。
它能在我编辑器里打开出错的那份文件吗?可以——它的内置功能之一,就是可以直接从错误页面在你常用的编辑器和 IDE 里打开相关文件。
What are similar projects?monolog, guzzle, echo, axum, martini, Slim, jwt-auth, loguru
Creator
filp
Size
1.7 MB
Stars
13.2K
Updated
CommitOct 03
Age
13y
Commits · 90 Days