php whoops用法,whoops: Whoops 适用于PHP环境的错误捕获与调试PHP库; whoops非常容易使用,它提供stack-based错误捕获及超美观的错误查看...

whoops

PHP errors for cool kids

whoops.svg

whoops.svg

badge.svg

whoops.svg?branch=master

quality-score.png?s=6225c36f2a2dd1fdca11ecc7b10b29105c8c62bd

coverage.png?s=711feb2069144d252d111b211965ffb19a7d09a8

c8abc405d4ea17abde98517946df2d48.png

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 handlers for different response formats (JSON, XML, SOAP)

Easy to extend and integrate with existing libraries

Clean, well-structured & tested code-base

Sponsors

426626a39f13909b40ef67bccd999b1f.png

Installing

If you use Laravel 4, Laravel 5.5+ or Mezzio, 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:

Use Composer to install Whoops into your project:

composer require filp/whoops

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:

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值