whoops

whoops 是PHP的错误处理程序框架。开箱即用。(whoops is an error handler framework for PHP. Out-of-the-box.)

Github星跟蹤圖

whoops 是PHP的错误处理程序框架。开箱即用,它提供了一个漂亮的错误界面,可以帮助您调试您的Web项目,但从本质上 讲,它是一个简单但功能强大的堆栈错误处理系统。

功能

  • 灵活的、基于堆栈的错误处理
  • 具有(当前)没有必需依赖项的独立库
  • 用于处理异常,跟踪帧及其数据的简单API
  • 为您的webapp项目包含一个漂亮的rad错误页面
  • 包括直接在您的编辑器和IDE中打开引用文件
  • 包含用于不同响应格式(JSON,XML,SOAP)的处理程序
  • 易于扩展并与现有库集成
  • 干净,结构良好且经过测试的代码库

安装

如果你使用Laravel 4或Laravel 5.5+,你已经有了Whoops。还有社区提供的关于如何整合Whoops的说明 Silex 1 Silex 2 Phalcon Laravel 3 Laravel 5 CakePHP 2 CakePHP 3 Zend 2 Zend 3 Yii 1 FuelPHP SlimPimple, 或任何使用 StackPHP中间件的框架 或 PSR-7中间件

如果您没有使用任何这些框架,请使用以下简单的安装方式:

  1. 使用Composer将Whoops安装到您的项目中:
    composer require filp/whoops    
  2. 在代码中注册漂亮的处理程序:
    $whoops = new \Whoops\Run;
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
    $whoops->register();    

如需更多选项,请查看 examples/中的示例文件,以了解事情的工作方式。另请参阅 API文档以及下面的可用代码列表。

您可能还想覆盖一些系统调用Whoops的功能。为此,请扩展 Whoops\Util \SystemFacade ,覆盖所需的函数并将其作为参数传递给 Run 构造函数。

可用的处理程序

whoops 目前附带有 Whoops\Handler 命名空间中提供的以下内置处理程序:

  • PrettyPageHandler - 显示一个当某些东西变得不合时宜时,出现错误页面
  • PlainTextHandler - 输出简单用于CLI应用程序的文本消息
  • CallbackHandler - 将闭包或其他可调用的处理程序包装为处理程序。您不需要明确使用此处理程序, whoops 将自动包装任何闭包或可调用,您传递给 Whoops\Run::pushHandler
  • JsonResponseHandler - 捕获异常并将它们的信息作为JSON字符串返回。例如,可以用来和AJAX请求一起玩。
  • XmlResponseHandler - 捕获异常并将它们的信息作为XML字符串返回。例如,可以用来和AJAX请求一起玩。

您也可以使用可插入的处理程序,例如 SOAP处理程序

作者

这个库主要由 Filipe Dobreira 开发,目前由丹尼斯索科洛夫各位贡献者也发送了许多令人敬畏的修复和增强功能。特别感谢 Graham Campbell Markus Staab 的持续参与。

此软件包含Prettify,在Apache许可证2.0下授权。它仅作为性能优化捆绑在一起。

主要指標

概覽
名稱與所有者filp/whoops
主編程語言PHP
編程語言PHP (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2013-03-11 16:58:27
推送於2025-06-11 20:42:42
最后一次提交2025-06-11 22:42:19
發布數82
最新版本名稱2.18.2 (發布於 )
第一版名稱0.8.4 (發布於 2013-03-15 20:31:09)
用户参与
星數13.2k
關注者數188
派生數602
提交數1.2k
已啟用問題?
問題數358
打開的問題數7
拉請求數310
打開的拉請求數3
關閉的拉請求數106
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

whoops

PHP errors for cool kids

Total Downloads
Latest Version
Reference Status
Dependency Status
Build Status
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

  • Flexible, stack-based error handling
  • Stand-alone library with (currently) no required dependencies
  • Simple API for dealing with exceptions, trace frames & their data
  • Includes a pretty rad error page for your webapp projects
  • Includes the ability to open referenced files directly in your editor and IDE
  • Includes handlers for different response formats (JSON, XML, SOAP)
  • Easy to extend and integrate with existing libraries
  • Clean, well-structured & tested code-base

Sponsors

Installing

If you use Laravel 4 or Laravel 5.5+, 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 2,
CakePHP 3,
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.

Available Handlers

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

  • PrettyPageHandler - Shows a pretty error page when something goes pants-up
  • PlainTextHandler - Outputs plain text message for use in CLI applications
  • CallbackHandler - Wraps a closure or other callable as a handler. You do not need to use this handler explicitly, whoops will automatically wrap any closure or callable you pass to Whoops\Run::pushHandler
  • JsonResponseHandler - Captures exceptions and returns information on them as a JSON string. Can be used to, for example, play nice with AJAX requests.
  • XmlResponseHandler - Captures exceptions and returns information on them as a XML string. Can be used to, for example, play nice with AJAX requests.

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.

This software includes Prettify, licensed under Apache License 2.0. It is bundled only as a performance optimization.