PHPackages                             php-errors/php-errors - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. php-errors/php-errors

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

php-errors/php-errors
=====================

重写PHP错误处理程序，捕获所有PHP运行时错误并支持通过设置日志器将错误日志记录到日志中。

v1.1.0(9y ago)241MITPHPPHP &gt;=5.3.0

Since May 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/KomaBeyond/php-errors)[ Packagist](https://packagist.org/packages/php-errors/php-errors)[ RSS](/packages/php-errors-php-errors/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

php-errors
==========

[](#php-errors)

PHP错误处理组件，可捕获PHP运行时的所有错误，通过设置错误报告级别及日志记录器，将PHP运行时的错误信息记录到日志中。 日志记录接口需遵守 prs-0 规范。支持通过设置 displayErrors 参数为 true 将错误信息打印到页面上。
通过推荐的 php.ini 配置来初始化 PHP 环境，再这之后的所有错误信息交给 php-errors 组件即可。

推荐 php.ini 配置（dev &amp; pro）
============================

[](#推荐-phpini-配置dev--pro)

```
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = 错误日志记录位置（绝对路径，也可以设置为 syslog，将日志打印到系统日志中）
error_reporting = E_ALL & E_STRICT

//php-fpm 环境下还应该设置 php-fpm 的配置，如下：通常位于 /path/to/fpm/pool.d/www.conf
catch_workers_output = yes
```

#### 上述设置中的 error\_log 文件位置仅仅作为备用日志文件地址，当没有设置日志记录器时，日志默认会被填充到该位置（推荐设置日志记录器）。

[](#上述设置中的-error_log-文件位置仅仅作为备用日志文件地址当没有设置日志记录器时日志默认会被填充到该位置推荐设置日志记录器)

install
=======

[](#install)

```
{
    "require": {
        "php-errors/php-errors": "~1.0"
    }
}
```

使用
==

[](#使用)

```
$baseDir = dirname(__DIR__);
require $baseDir.'/vendor/autoload.php';

$errorHandler = \PHPErrors\PHPErrors::enable(E_ALL, true);

//以下代码可选，用来设置日志记录器（推荐这么做）
$logger = new \Monolog\Logger("test");
$logger->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__."/test.log"));
$errorHandler->setLogger($logger);
```

建议
===

[](#建议-)

应用代码中对于应用异常处理应通过 try/catch 代码块来捕获，否则异常会被 php-errors 捕获并记录到日志中。

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

3319d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/164877216?v=4)[KomaBeyond](/maintainers/KomaBeyond)[@komabeyond](https://github.com/komabeyond)

---

Top Contributors

[![Kooooooma](https://avatars.githubusercontent.com/u/5483460?v=4)](https://github.com/Kooooooma "Kooooooma (13 commits)")

---

Tags

phpphp-errorsphp-exceptionpsr-0

### Embed Badge

![Health badge](/badges/php-errors-php-errors/health.svg)

```
[![Health](https://phpackages.com/badges/php-errors-php-errors/health.svg)](https://phpackages.com/packages/php-errors-php-errors)
```

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k247.1M335](/packages/sentry-sentry)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.3M623](/packages/illuminate-log)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M219](/packages/api-platform-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
