1.1.2 2015-08-03 03:17 UTC

This package is not auto-updated.

Last update: 2024-04-09 00:37:06 UTC


Latest Stable Version Build Status

This middleware append PHP Debug Bar to Slim response.

Inspired by Laravel 4 DebugBar


Custom Collectors

  • SlimEnvCollector (collect slim mode and version)
  • SlimViewCollector (collect view variables)
  • SlimRouteCollector (collect matched route information)
  • SlimResponseCollector (collect response headers and cookies)

DebugBar Default Collectors

  • SlimCollector
  • PhpInfoCollector
  • ConfigCollector
  • RequestDataCollector
  • TimeDataCollector
  • MemoryCollector


Require this package in your composer.json

"yusukezzz/slim-debugbar": "1.*"


require '/path/to/vendor/autoload.php';
$config = [];
// if you want to capture ajax requests, set instance of StorageInterface implemented.
// $config['debugbar.storage'] = new \DebugBar\Storage\FileStorage('/path/to/storage');
$slim = new \Slim\Slim($config);
$debugbar = new \Slim\Middleware\DebugBar();
// you can add custom collectors
//  $debugbar->addCollector(new MyCustomCollector());
// or use custom debugbar
//  $debugbar->setDebugBar(new MyCustomDebugBar());
$slim->get('/', function()
    echo 'Hello world!';


  • Please use real httpd (apache, nginx etc...)
    • PHP builtin server does not supported.
  • Available storage for ajax capturing
  • Redirection data stack
    • support PHP native session only (session_start() required)
    • if you want to use your own session manager, you should implement DebugBar\HttpDriverInterface.
  • Reserved route for DebugBar
    • /_debugbar/fonts/:file
      • for fontawesome files
    • /_debugbar/resources/:file
      • for css, javascript
    • /_debugbar/openhandler
      • for previous sets of collected data

Custom Session Manager example

require '/path/to/vendor/autoload.php';
class MyHttpDriver implements \DebugBar\HttpDriverInterface
    protected $session;
    protected $response;
    public function __construct(YourSessionManager $session, \Slim\Http\Response $response)
        $this->session = $session;
        $this->response = $response;
    public function setHeaders(array $headers)
        foreach ($headers as $key => $val) {
            $this->response->header($key, $val);
    public function isSessionStarted()
        return $this->session->isStarted();
    // You should implement other methods too
$slim = new \Slim\Slim();
$slim->container->singleton('session', function()
    return new YourSessionManager();
$driver = new MyHttpDriver($slim->session, $slim->response);
$debugbar = new \Slim\Middleware\DebugBar($driver);
$slim->get('/', function()
    echo 'Hello world!';
$slim->get('/redirect', function() use ($slim)


  • Q. Errors in the browser's console: Resource interpreted as Font but transferred with MIME type text/html