PHPackages                             responsive-sk/php-debugbar-middleware - 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. responsive-sk/php-debugbar-middleware

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

responsive-sk/php-debugbar-middleware
=====================================

Modern PSR-15 middleware for PHP DebugBar with automatic asset serving. Works with Mezzio, Slim 4, Symfony, and any PSR-15 framework.

v1.0.2(10mo ago)0101MITPHPPHP ^8.2CI failing

Since Jul 16Pushed 10mo agoCompare

[ Source](https://github.com/responsive-sk/php-debugbar-middleware)[ Packagist](https://packagist.org/packages/responsive-sk/php-debugbar-middleware)[ Docs](https://github.com/responsive-sk/php-debugbar-middleware)[ RSS](/packages/responsive-sk-php-debugbar-middleware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (11)Versions (5)Used By (0)

PHP DebugBar Middleware
=======================

[](#php-debugbar-middleware)

[![Latest Version](https://camo.githubusercontent.com/7f309423234c6f439685e2bf8b8cb8b1106095a20475e687aa20fccb97aa0a7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726573706f6e736976652d736b2f7068702d64656275676261722d6d6964646c65776172652e737667)](https://packagist.org/packages/responsive-sk/php-debugbar-middleware)[![PHP Version](https://camo.githubusercontent.com/885f3ee0555016d68d43f5aaa0898553b878d95d4de86e02a1ddff92ae73a76a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f726573706f6e736976652d736b2f7068702d64656275676261722d6d6964646c65776172652e737667)](https://packagist.org/packages/responsive-sk/php-debugbar-middleware)[![License](https://camo.githubusercontent.com/d951515a181eb22290de78b4877661e4925434591e6d434c478935e782b2d3cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726573706f6e736976652d736b2f7068702d64656275676261722d6d6964646c65776172652e737667)](https://packagist.org/packages/responsive-sk/php-debugbar-middleware)[![Tests](https://github.com/responsive-sk/php-debugbar-middleware/workflows/Tests/badge.svg)](https://github.com/responsive-sk/php-debugbar-middleware/actions)

Modern PSR-15 middleware for [PHP DebugBar](http://phpdebugbar.com/) with automatic asset serving and zero configuration. Works seamlessly with **Mezzio**, **Slim 4**, **Symfony**, and any PSR-15 compatible framework.

✨ Features
----------

[](#-features)

- 🚀 **Zero Configuration** - Works out of the box
- 🎯 **Automatic Asset Serving** - No manual asset copying required
- 🔒 **Security First** - Path traversal protection and development-only activation
- ⚡ **High Performance** - Minimal overhead, production-safe
- 🎨 **Full Styling** - Complete CSS/JS with Font Awesome icons
- 🔧 **Framework Agnostic** - Works with any PSR-15 framework
- 📱 **Modern PHP** - Requires PHP 8.2+, strict types, comprehensive typing

📦 Installation
--------------

[](#-installation)

```
composer require --dev responsive-sk/php-debugbar-middleware
```

🚀 Quick Start
-------------

[](#-quick-start)

### Mezzio / Laminas

[](#mezzio--laminas)

```
// config/config.php
$configManager = new ConfigManager([
    ResponsiveSk\PhpDebugBarMiddleware\ConfigProvider::class,
    // ... your other config providers
]);

// config/pipeline.php
$app->pipe(ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware::class);

// src/App/RoutesDelegator.php (REQUIRED for assets)
$app->get('/debugbar/{file:.+}', [\ResponsiveSk\PhpDebugBarMiddleware\DebugBarAssetsHandler::class], 'debugbar::assets');
```

### Slim 4

[](#slim-4)

```
use ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware;
use ResponsiveSk\PhpDebugBarMiddleware\DebugBarAssetsHandler;

$app = AppFactory::create();

// Add middleware
$app->add(DebugBarMiddleware::class);

// Add asset route
$app->get('/debugbar/{file:.+}', DebugBarAssetsHandler::class);
```

### Symfony (with PSR-15 Bridge)

[](#symfony-with-psr-15-bridge)

```
// config/services.yaml
services:
    ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware:
        tags: ['middleware']
```

### Manual Setup (Any PSR-15 Framework)

[](#manual-setup-any-psr-15-framework)

```
use ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware;
use ResponsiveSk\PhpDebugBarMiddleware\DebugBarAssetsHandler;

// Create middleware
$debugBarMiddleware = new DebugBarMiddleware();

// Add to your middleware stack
$middlewareStack->add($debugBarMiddleware);

// Add asset handler to your router
$router->get('/debugbar/{file:.+}', new DebugBarAssetsHandler());
```

🎛️ Configuration
----------------

[](#️-configuration)

### Environment-Based Activation

[](#environment-based-activation)

DebugBar automatically activates in development and deactivates in production:

```
# Development (DebugBar active)
APP_ENV=development
DEBUG=true

# Production (DebugBar inactive)
APP_ENV=production
DEBUG=false
```

### Custom Configuration

[](#custom-configuration)

```
// config/autoload/debugbar.local.php
return [
    'debugbar' => [
        'enabled' => true,
        'collectors' => [
            'messages' => true,
            'time' => true,
            'memory' => true,
            'exceptions' => true,
            'request' => true,
        ],
        'asset_path' => '/debugbar',
    ],
];
```

🔧 Framework-Specific Examples
-----------------------------

[](#-framework-specific-examples)

### Mezzio Complete Setup

[](#mezzio-complete-setup)

```
// config/config.php
use Laminas\ConfigAggregator\ConfigAggregator;
use ResponsiveSk\PhpDebugBarMiddleware\ConfigProvider;

$aggregator = new ConfigAggregator([
    ConfigProvider::class,
    // ... other providers
]);

return $aggregator->getMergedConfig();

// config/pipeline.php
$app->pipe(ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware::class);

// src/App/RoutesDelegator.php
public function __invoke(ContainerInterface $container, string $serviceName, callable $callback): Application
{
    /** @var Application $app */
    $app = $callback();

    // Your application routes
    $app->get('/', [HomePageHandler::class], 'home');

    // DebugBar assets route (REQUIRED for CSS/JS)
    $app->get('/debugbar/{file:.+}', [\ResponsiveSk\PhpDebugBarMiddleware\DebugBarAssetsHandler::class], 'debugbar::assets');

    return $app;
}
```

### Slim 4 with Container

[](#slim-4-with-container)

```
use DI\Container;
use ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware;

$container = new Container();
$app = AppFactory::createFromContainer($container);

// Register middleware
$container->set(DebugBarMiddleware::class, function() {
    return new DebugBarMiddleware();
});

$app->add(DebugBarMiddleware::class);
```

📊 What You Get
--------------

[](#-what-you-get)

- **Request Timeline** - See exactly where time is spent
- **Memory Usage** - Track memory consumption
- **Exception Tracking** - Catch and display errors
- **Request Data** - Inspect GET/POST/COOKIE data
- **Custom Messages** - Add your own debug messages
- **Database Queries** - Monitor SQL performance (with additional collectors)

🛡️ Security
-----------

[](#️-security)

- **Development Only** - Automatically disabled in production
- **Path Traversal Protection** - Secure asset serving
- **No External Dependencies** - All assets served locally
- **Environment Detection** - Respects APP\_ENV and DEBUG settings

🎨 Styling
---------

[](#-styling)

DebugBar appears with full styling including:

- Font Awesome icons
- Responsive design
- Dark/light theme support
- Professional appearance
- Zero configuration required

🧪 Testing
---------

[](#-testing)

```
# Run tests
composer test

# Run with coverage
composer test-coverage

# Static analysis
composer phpstan

# Code style check
composer cs-check

# Fix code style
composer cs-fix

# Run all quality checks
composer quality
```

📈 Performance
-------------

[](#-performance)

- **Zero Production Impact** - Completely disabled in production
- **Minimal Development Overhead** - Optimized for development workflow
- **Efficient Asset Serving** - Direct file serving without processing
- **Memory Efficient** - Lazy loading and minimal memory footprint

🎨 Custom Branding
-----------------

[](#-custom-branding)

Want to use your own logo instead of the default? Check out our comprehensive [Branding Guide](docs/BRANDING.md) with examples for:

- **Custom Logo Integration** - Replace with your company logo
- **Theme Customization** - Match your brand colors
- **Framework-Specific Examples** - Ready-to-use configurations
- **Best Practices** - Design and performance guidelines

🚀 Roadmap &amp; Future Enhancements
-----------------------------------

[](#-roadmap--future-enhancements)

See our [Roadmap](docs/ROADMAP.md) for planned features and enhancement ideas:

- Database query collectors
- Advanced performance monitoring
- Mobile-responsive design
- Plugin system architecture
- Enterprise features

🔧 Troubleshooting
-----------------

[](#-troubleshooting)

### DebugBar appears but CSS/JS assets return 404

[](#debugbar-appears-but-cssjs-assets-return-404)

**Problem**: DebugBar HTML is injected but assets (CSS/JS) are not loading.

**Solution**: Make sure you've registered the assets route:

```
// In your RoutesDelegator or routes configuration
$app->get('/debugbar/{file:.+}', [\ResponsiveSk\PhpDebugBarMiddleware\DebugBarAssetsHandler::class], 'debugbar::assets');
```

### DebugBar doesn't appear at all

[](#debugbar-doesnt-appear-at-all)

**Causes &amp; Solutions**:

1. **Environment Detection**: DebugBar only appears in development

    ```
    # Set environment variables
    export APP_ENV=development
    export DEBUG=true
    ```
2. **Middleware Not Registered**: Ensure middleware is in pipeline

    ```
    // config/pipeline.php
    $app->pipe(ResponsiveSk\PhpDebugBarMiddleware\DebugBarMiddleware::class);
    ```
3. **ConfigProvider Not Loaded**: Check config aggregation

    ```
    // config/config.php
    $configManager = new ConfigManager([
        ResponsiveSk\PhpDebugBarMiddleware\ConfigProvider::class,
        // ... other providers
    ]);
    ```

### Class not found errors

[](#class-not-found-errors)

**Solution**: Regenerate autoloader

```
composer dump-autoload
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

🙏 Credits
---------

[](#-credits)

- Built by [Responsive.sk](https://responsive.sk)
- Based on [PHP DebugBar](http://phpdebugbar.com/) by Maxime Bouroumeau-Fuseau
- Inspired by the Laravel DebugBar package

🔗 Related Packages
------------------

[](#-related-packages)

- [php-debugbar/php-debugbar](https://github.com/php-debugbar/php-debugbar) - The core DebugBar library
- [responsive-sk/slim4-paths](https://github.com/responsive-sk/slim4-paths) - Path management for PHP applications

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance55

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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

3

Last Release

302d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9ca94d5516a8f930325df47de8418a33caf484280105d108a693533c73d4699?d=identicon)[evan70](/maintainers/evan70)

---

Top Contributors

[![evan70](https://avatars.githubusercontent.com/u/67433?v=4)](https://github.com/evan70 "evan70 (3 commits)")

---

Tags

agnosticdebuggerdebugging-toolnative-appsphpphp-frameworkphp8psr-7phpmiddlewaresymfonylaminasdebugbardebuggingslimdevelopmentpsr-15mezzio

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/responsive-sk-php-debugbar-middleware/health.svg)

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

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

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

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.0M61](/packages/mezzio-mezzio-router)[mezzio/mezzio-swoole

Swoole support for Mezzio

92238.9k3](/packages/mezzio-mezzio-swoole)[mezzio/mezzio-helpers

Helper/Utility classes for Mezzio

134.3M67](/packages/mezzio-mezzio-helpers)

PHPackages © 2026

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