confetticode/error-handler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

confetticode/error-handler

Composer 安装命令:

composer require confetticode/error-handler

包简介

A great unified error handler for PHP

关键字:

README 文档

README

Installation

Install confetticode/error-handler as a Composer dependency in your project.

composer require confetticode/error-handler

Usage

Create a new instance of the ErrorHandler class. By default, HtmlDisplayer will be initialized. This will display an error html page with status code, message and short description.

$errors = new \Confetti\ErrorHandler\ErrorHandler();

Register the $errors instance as the global error handler by doing some logic with set_error_handler, set_exception_handler and register_shutdown_function. Then, any uncaught errors/exceptions will be handled.

$errors->register();

You can change displayer by calling the setDisplayer method.

// Natively available.
$errors->setDisplayer(new \ConfetiCode\ErrorHandler\SymfonyDisplayer);

// To use IgnitionDisplayer, you have to install "spatie/ignition".
$errors->setDisplayer(new \ConfetiCode\ErrorHandler\IgnitionDisplayer);

Integrate with monolog/monolog, eg: writing logs into files.

composer require monolog/monolog
$logger = new \Monolog\Logger('testing');

$logger->setHandlers([
    new \Monolog\Handler\StreamHandler(__DIR__.'/log.txt'),
]);

$reporter = new \ConfettiCode\ErrorHandler\LogReporter($logger);

$errors->setReporter($reporter);

You may try out error.php file for a quick overview.

License

The confetticode/error-handler package is licensed under the MIT license.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-20