dotkernel/dot-errorhandler 问题修复 & 功能扩展

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

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

dotkernel/dot-errorhandler

最新稳定版本:4.4.2

Composer 安装命令:

composer require dotkernel/dot-errorhandler

包简介

Logging Error Handler for Middleware Applications

README 文档

README

dot-errorhandler is Dotkernel's PSR-15 compliant error handler.

Version History

Branch Release PSR-11 Log Style Implementation OSS Lifecycle PHP Version
4.1 >= 4.2 2 PSR-Log OSS Lifecycle PHP from Packagist (specify version)
4.1 < 4.2 2 Laminas Log OSS Lifecycle PHP from Packagist (specify version)
4.0 < 4.1 1 Laminas Log OSS Lifecycle PHP from Packagist (specify version)
3.0 < 4.0 1 Laminas Log OSS Lifecycle PHP from Packagist (specify version)

Documentation

Documentation is available at: https://docs.dotkernel.org/dot-errorhandler/

Badges

OSS Lifecycle PHP from Packagist (specify version)

GitHub issues GitHub forks GitHub stars GitHub license

Build Static codecov PHPStan

Adding the error handler

  • Add the composer package:
composer require dotkernel/dot-errorhandler
  • Add the config provider:
    • in config/config.php add \Dot\ErrorHandler\ConfigProvider
    • in config/pipeline.php add \Dot\ErrorHandler\ErrorHandlerInterface::class
      • the interface is used as an alias to keep all error handling related configurations in one file

If you need other error handlers, you should place them before dot-errorhandler in the pipeline; else it will not be able to catch errors. We recommend using just one error handler unless you have an error-specific handler.

  • Configure the error handler as shown below.

In config/autoload/error-handling.global.php:

<?php use Dot\ErrorHandler\ErrorHandlerInterface; use Dot\ErrorHandler\LogErrorHandler; return [ 'dependencies' => [ 'aliases' => [ ErrorHandlerInterface::class => LogErrorHandler::class, ], ], 'dot-errorhandler' => [ 'loggerEnabled' => true, 'logger' => 'dot-log.default_logger', ] ];

A configuration example for the default logger can be found in config/log.global.php.dist.

When configuring the error handler in your application, you can choose between two classes:

  • Dot\ErrorHandler\LogErrorHandler: for logging and displaying errors
  • Dot\ErrorHandler\ErrorHandler: for displaying errors only

Both LogErrorHandler and ErrorHandler have factories declared in the package's ConfigProvider. If you need a custom ErrorHandler, it must have a factory declared in the config, as in the below example:

Example:

<?php declare(strict_types=1); return [ 'dependencies' => [ 'factories' => [ \App\CustomErrorHandler::class => \App\CustomHandlerFactory::class, ], 'aliases' => [ \Dot\ErrorHandler\ErrorHandlerInterface::class => \App\CustomErrorHandler::class, ], ], 'dot-errorhandler' => [ 'loggerEnabled' => true, 'logger' => 'dot-log.default_logger', ], ];

Config examples can be found in this project's config directory.

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固