PHPackages                             php-middleware/php-debug-bar - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. php-middleware/php-debug-bar

ActiveLibrary[HTTP &amp; Networking](/categories/http)

php-middleware/php-debug-bar
============================

PHP Debug Bar PSR-15 middleware with PSR-7

4.2.0(4y ago)76433.5k↑36.7%19[5 issues](https://github.com/php-middleware/phpdebugbar/issues)[1 PRs](https://github.com/php-middleware/phpdebugbar/pulls)2MITPHPPHP ^7.3 || ^8.0

Since Aug 31Pushed 2y ago5 watchersCompare

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

READMEChangelog (10)Dependencies (14)Versions (19)Used By (2)

phpdebugbar middleware [![Build Status](https://camo.githubusercontent.com/9c191b5b97c4296bdc5b94578351af585977413b3ab307a16295b33ecfe1102a/68747470733a2f2f7472617669732d63692e6f72672f7068702d6d6964646c65776172652f70687064656275676261722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-middleware/phpdebugbar)
====================================================================================================================================================================================================================================================================================================================================

[](#phpdebugbar-middleware-)

[PHP Debug Bar](http://phpdebugbar.com/) as framework-agnostic [PSR-15 middleware](https://www.php-fig.org/psr/psr-15/) with [PSR-7 messages](https://www.php-fig.org/psr/psr-7/) created by [PSR-17 message factories](https://www.php-fig.org/psr/psr-17/). Also provides [PSR-11 container invokable factories](https://www.php-fig.org/psr/psr-11/).

Framework-agnostic way to attach [PHP Debug Bar](http://phpdebugbar.com/) to your response (html or non-html!).

Installation
------------

[](#installation)

```
composer require --dev php-middleware/php-debug-bar

```

To build middleware you need to inject `DebugBar\JavascriptRenderer` (you can get it from `DebugBar\StandardDebugBar`) inside `PhpDebugBarMiddleware` and add it into your middleware runner:

```
$debugbar = new DebugBar\StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer('/phpdebugbar');
$middleware = new PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware($debugbarRenderer, $psr17ResponseFactory, $psr17StreamFactory);

// or use provided factory
$factory = new PhpMiddleware\PhpDebugBar\PhpDebugBarMiddlewareFactory();
$middleware = $factory($psr11Container);

$app = new MiddlewareRunner();
$app->add($middleware);
$app->run($request, $response);
```

You don't need to copy any static assets from phpdebugbar vendor!

### How to force disable or enable PHP Debug Bar?

[](#how-to-force-disable-or-enable-php-debug-bar)

Sometimes you want to have control when enable or disable PHP Debug Bar:

- custom content negotiation,
- allow debug redirects responses.

We allow you to disable attaching phpdebugbar using `X-Enable-Debug-Bar: false` header, cookie or request attribute. To force enable just send request with `X-Enable-Debug-Bar` header, cookie or request attribute with `true` value.

### PSR-17

[](#psr-17)

This package isn't require any PSR-7 implementation - you need to provide it by own. Middleware require ResponseFactory and StreamFactory interfaces. [List of existing interfaces](https://packagist.org/providers/psr/http-factory-implementation).

#### ... and PSR-11

[](#-and-psr-11)

If you use provided PSR-11 factories, then your container must have services registered as PSR-17 interface's name. Example for [laminas-diactoros](https://github.com/laminas/laminas-diactoros) implementation and [Pimple](https://pimple.symfony.com/):

```
$container[Psr\Http\Message\ResponseInterface::class] = new Laminas\Diactoros\ResponseFactory();
$container[Psr\Http\Message\StreamFactoryInterface::class] = new Laminas\Diactoros\StreamFactory();
```

### How to install on Mezzio?

[](#how-to-install-on-mezzio)

You need to register `PhpMiddleware\PhpDebugBar\ConfigProvider` and pipe provided middleware:

```
$app->pipe(\PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware::class);
```

For more - follow Mezzio [documentation](https://docs.mezzio.dev/mezzio/v3/features/modular-applications/).

### How to install on Slim 3?

[](#how-to-install-on-slim-3)

Register factories in container:

```
foreach (ConfigProvider::getConfig()['dependencies']['factories'] as $key => $factory) {
    $container[$key] = new $factory();
}
```

and add middleware from container to app:

```
$app->add(
    $app->getContainer()->get(\PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware::class)
);
```

### How to configure using existing factories?

[](#how-to-configure-using-existing-factories)

Put array with a configuration into `PhpMiddleware\PhpDebugBar\ConfigProvider` service in your container:

```
return [
    'phpmiddleware' => [
        'phpdebugbar' => [
            'javascript_renderer' => [
                'base_url' => '/phpdebugbar',
            ],
            'collectors' => [
                DebugBar\DataCollector\ConfigCollector::class, // Service names of collectors
            ],
            'storage' => null, // Service name of storage
        ],
    ],
];
```

You can override existing configuration by merge default configuration with your own (example):

```
return array_merge(PhpMiddleware\PhpDebugBar\ConfigProvider::getConfig(), $myOverritenConfig);
```

It's just works with any modern php framework!
----------------------------------------------

[](#its-just-works-with-any-modern-php-framework)

Middleware tested on:

- [Mezzio](https://github.com/mezzio/mezzio)
- [Slim 3.x](https://github.com/slimphp/Slim)

And any other modern framework [supported PSR-17 middlewares and PSR-7](https://mwop.net/blog/2015-01-08-on-http-middleware-and-psr-7.html).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 88% 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 ~139 days

Recently: every ~241 days

Total

18

Last Release

1546d ago

Major Versions

1.4.1 → 2.0.02018-04-11

2.1.1 → 3.0.02018-10-15

3.1.0 → 4.0.02020-05-12

PHP version history (6 changes)1.0.1PHP &gt;=5.5

1.1.0PHP ^5.5 || ^7.0

1.4.0PHP &gt;=5.6

2.0.0PHP ^7.1

4.0.0PHP ^7.2

4.1.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/93a2113828a101b473d256ef12e6bd89d67bcbef0621704cfeb3304c98a16a47?d=identicon)[snapshotpl](/maintainers/snapshotpl)

---

Top Contributors

[![snapshotpl](https://avatars.githubusercontent.com/u/312655?v=4)](https://github.com/snapshotpl "snapshotpl (73 commits)")[![prolic](https://avatars.githubusercontent.com/u/394428?v=4)](https://github.com/prolic "prolic (7 commits)")[![llaville](https://avatars.githubusercontent.com/u/364342?v=4)](https://github.com/llaville "llaville (2 commits)")[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (1 commits)")

---

Tags

debugger-toolbardebugging-toolmiddlewarepsr-15psr-7psrpsr-7middlewarePSR-11debugpsr-15

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-middleware-php-debug-bar/health.svg)

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

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[mezzio/mezzio-skeleton

Laminas mezzio skeleton. Begin developing PSR-15 middleware applications in seconds!

12726.2k](/packages/mezzio-mezzio-skeleton)

PHPackages © 2026

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