GithubHelp home page GithubHelp logo

middlewares / debugbar Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 5.0 44 KB

PSR-15 middleware to insert PHP DebugBar automatically in html responses

License: MIT License

PHP 100.00%
debugbar http psr-15 middleware debugger

debugbar's Introduction

middlewares/debugbar

Latest Version on Packagist Software License Testing Total Downloads

Middleware to insert PHP DebugBar automatically in html responses.

Requirements

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/maximebf/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/maximebf/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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.