PHPackages                             fastd/debug - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. fastd/debug

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

fastd/debug
===========

error handle component.

v2.0.3(9y ago)12.2k22MITPHPPHP &gt;=7.0

Since Jul 20Pushed 9y ago1 watchersCompare

[ Source](https://github.com/JanHuang/debug)[ Packagist](https://packagist.org/packages/fastd/debug)[ RSS](/packages/fastd-debug/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (28)Used By (2)

Debug
=====

[](#debug)

[![Latest Stable Version](https://camo.githubusercontent.com/e0bfaee5684e688ea1f1b596dd191d8d66b3b124c28162091516a1b2d915bf15/68747470733a2f2f706f7365722e707567782e6f72672f66617374642f64656275672f762f737461626c65)](https://packagist.org/packages/fastd/debug) [![Total Downloads](https://camo.githubusercontent.com/d7f09cbb54d88666576d261c21e7723d47b95bc289b2b2ac3fc2b377533bb922/68747470733a2f2f706f7365722e707567782e6f72672f66617374642f64656275672f646f776e6c6f616473)](https://packagist.org/packages/fastd/debug) [![Latest Unstable Version](https://camo.githubusercontent.com/e53b3e2fba604dd9fb5efb3194004838332b52d14f45bfa647d7b51e004be4d8/68747470733a2f2f706f7365722e707567782e6f72672f66617374642f64656275672f762f756e737461626c65)](https://packagist.org/packages/fastd/debug) [![License](https://camo.githubusercontent.com/394e16f2bca1956fb5f21b6abe1d058e52e3534eb757e851a66b580cb1560912/68747470733a2f2f706f7365722e707567782e6f72672f66617374642f64656275672f6c6963656e7365)](https://packagist.org/packages/fastd/debug)

支持自定义错误页面，自定义响应格式，响应头，支持 fatal error 捕捉，日志纪录等功能。

要求
--

[](#要求)

- PHP 7+

Composer
--------

[](#composer)

```
{
    "fastd/debug": "2.0.x-dev"
}
```

使用
--

[](#使用)

```
use FastD\Debug\Debug;
Debug::enable();
trigger_error('demo');
```

日志使用 `Monolog\Logger`, 完全自定义 `Monolog\Logger` 日志，直接注入到 `FastD/Debug` 对象中即可

```
$logger = new \Monolog\Logger('test');
$stream = new \Monolog\Handler\StreamHandler(__DIR__ . '/test.log');
$stream->setFormatter(new Monolog\Formatter\LineFormatter("[%datetime%] >> %level_name%: >> %message% >> %context% >> %extra%\n"));
$logger->pushHandler($stream);

$debug = \FastD\Debug\Debug::enable(false, $logger);

throw new \Exception('test');
```

自定义错误页面内容

```
\FastD\Debug\Debug::enable();

class PageException extends \FastD\Debug\Exceptions\HttpException
{
    /**
     * Returns response content.
     *
     * @return string
     */
    public function getContent()
    {
        return file_get_contents(__DIR__ . '/demo.html');
    }
}

throw new PageException('custom');
```

自定义错误页面使用自定义异常类一样的做法，可以更加灵活处理。

### 自定义异常

[](#自定义异常)

自定义异常只需要继承 `FastD\Debug\Exceptions\Http\HttpException` 对象，对类中的 `getStatusCode`, `getHeaders`, `getContent` 三个方法重写即可

可参考例子:

自定义响应格式: [json.php](examples/json.php)自定义页面: [page.php](examples/page.php)

Testing
-------

[](#testing)

```
phpunit

```

License MIT
-----------

[](#license-mit)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

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 ~23 days

Recently: every ~32 days

Total

27

Last Release

3343d ago

Major Versions

v0.1.1 → v1.0.0-BETA12015-08-08

v1.0.6 → v2.0.0-beta12016-05-11

v1.0.7 → 3.0.x-dev2016-11-14

PHP version history (3 changes)v0.1.0PHP &gt;=5.4

v2.0.0-beta1PHP &gt;=7.0

3.0.x-devPHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/94c2bc821caf23977e1c3deea85e3cbc9a73a632e1afaf778638f7fe9da1c42b?d=identicon)[JanHuang](/maintainers/JanHuang)

---

Top Contributors

[![JanHuang](https://avatars.githubusercontent.com/u/7090871?v=4)](https://github.com/JanHuang "JanHuang (90 commits)")

---

Tags

debugexceptionFastD

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fastd-debug/health.svg)

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

###  Alternatives

[snowair/phalcon-debugbar

Integrates PHP Debug Bar with Phalcon.

160123.3k1](/packages/snowair-phalcon-debugbar)[kuria/error

Makes handling and debugging PHP errors suck less

1920.0k2](/packages/kuria-error)[awesomite/error-dumper

Pretty preview of errors and exceptions

238.2k1](/packages/awesomite-error-dumper)

PHPackages © 2026

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