Debugbar
PSR-15 middleware to insert PHP DebugBar automatically in html responses
Install / Use
/learn @middlewares/DebugbarREADME
middlewares/debugbar
Middleware to insert PHP DebugBar automatically in html responses.
Requirements
- PHP >= 7.2
- A PSR-7 http library
- A PSR-15 middleware dispatcher
Installation
This package is installable and autoloadable via Composer as middlewares/debugbar.
composer require middlewares/debugbar
Example
$dispatcher = new Dispatcher([
new Middlewares\Debugbar()
]);
$response = $dispatcher->dispatch(new ServerRequest());
Usage
You can provide a DebugBar\DebugBar instance to the constructor or an instance of DebugBar\StandardDebugBar will be created automatically. Optionally, you can provide a Psr\Http\Message\ResponseFactoryInterface and Psr\Http\Message\StreamFactoryInterface to create the new responses. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.
//Create a StandardDebugBar automatically
$debugbar = new Middlewares\Debugbar();
//Use other Debugbar instance
$debugbar = new Middlewares\Debugbar($myDebugbar);
//Use other Debugbar instance and PSR-17 factories
$debugbar = new Middlewares\Debugbar($myDebugbar, $myResponseFactory, $myStreamFactory);
captureAjax
Use this option to capture ajax requests and send the data in the headers. More info about AJAX and Stacked data. By default it's disabled.
$debugbar = (new Middlewares\Debugbar())->captureAjax();
inline
Set true to dump the js/css code inline in the html. This fixes (or mitigate) some issues related with loading the debugbar assets.
$debugbar = (new Middlewares\Debugbar())->inline();
renderOptions
Use this option to pass render options to the debugbar as an array. A list of available options can be found at https://github.com/php-debugbar/php-debugbar/blob/master/src/DebugBar/JavascriptRenderer.php#L132
An example usage would be to pass a new location for the base_url so that you can rewrite the location of the files needed to render the debug bar. This can be used with symlinks, .htaccess or routes to the files to ensure the debugbar files are accessible.
$debugbar = (new Middlewares\Debugbar())->renderOptions(array('base_url' => "/MyProjectsSubDirectory/php-debugbar/php-debugbar"));
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.
Related Skills
node-connect
352.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
