Debug bar for PHP

Last update: May 26, 2022

PHP Debug Bar

Latest Stable Version Total Downloads License Tests

Displays a debug bar in the browser with information from php. No more var_dump() in your code!

Screenshot

Features:

  • Generic debug bar
  • Easy to integrate with any project
  • Clean, fast and easy to use interface
  • Handles AJAX request
  • Includes generic data collectors and collectors for well known libraries
  • The client side bar is 100% coded in javascript
  • Easily create your own collectors and their associated view in the bar
  • Save and re-open previous requests
  • Very well documented

Includes collectors for:

Checkout the demo for examples and phpdebugbar.com for a live example.

Integrations with other frameworks:

(drop me a message or submit a PR to add your DebugBar related project here)

Installation

The best way to install DebugBar is using Composer with the following command:

composer require maximebf/debugbar

Quick start

DebugBar is very easy to use and you can add it to any of your projects in no time. The easiest way is using the render() functions

<?php

// Require the Composer autoloader, if not already loaded
require 'vendor/autoload.php';

use DebugBar\StandardDebugBar;

$debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer();

$debugbar["messages"]->addMessage("hello world!");
?>
<html>
    <head>
        <?php echo $debugbarRenderer->renderHead() ?>
    </head>
    <body>
        ...
        <?php echo $debugbarRenderer->render() ?>
    </body>
</html>

The DebugBar uses DataCollectors to collect data from your PHP code. Some of them are automated but others are manual. Use the DebugBar like an array where keys are the collector names. In our previous example, we add a message to the MessagesCollector:

$debugbar["messages"]->addMessage("hello world!");

StandardDebugBar activates the following collectors:

  • MemoryCollector (memory)
  • MessagesCollector (messages)
  • PhpInfoCollector (php)
  • RequestDataCollector (request)
  • TimeDataCollector (time)
  • ExceptionsCollector (exceptions)

Learn more about DebugBar in the docs.

GitHub

https://github.com/maximebf/php-debugbar
Comments
  • 1. If body already has padding-bottom set, it's overwritten

    In my app the footer is fixed and positioned at the bottom. The body had padding-bottom set as 133px. The debug bar overwrites that and sets it at 26px which interferes with my styling.

    Can I suggest that the debug bar reads the padding first, and if it's not set or < 26 sets it, else ignores it?

    Reviewed by focalstrategy at 2014-08-17 15:24
  • 2. setDumpHeader error after upgrading symfony/var-dumper to v5.3.4

    After symfony/var-dumper was upgraded from v5.3.3 to v5.3.4 I'm getting:

    Symfony\Component\VarDumper\Dumper\HtmlDumper::setDumpHeader(): Argument #1 ($header) must be of type string, null given, called in /Users/user/Documents/dev/project/vendor/maximebf/debugbar/src/DebugBar/DataFormatter/DebugBarVarDumper.php on line 288

    Line 288 is $dumper->setDumpHeader(null);

    Not sure what is going on here but I'm guessing this is a bug?

    Reviewed by joostvanhoof at 2021-07-26 19:23
  • 3. FIX PHP 5.4 compat for using function return value in write context

    This restores compatibility with older PHP versions. v1.15.0 still allows PHP 5.3 or greater.

    It'd be great if you could release this in a 1.15.x patch, I realise it'll be slightly annoying since other commits exist in master already which bump these requirements.

    You can see the error here: https://travis-ci.org/lekoala/silverstripe-debugbar/jobs/508134678#L528

    Reviewed by robbieaverill at 2019-03-18 23:42
  • 4. Highlight duplicate SQL queries.

    As I'm debugging my app, I found it desirable to know where duplicate SQL queries were being made so that I could consider where caching might be necessary.

    This pull request adds the .phpdebugbar-widgets-sql-duplicate class to all queries that appear more than once. It also adds a .phpdebugbar-widgets-sql-duplicate-N class to each unique query that is duplicated.

    Reviewed by joshuajabbour at 2014-03-25 06:00
  • 5. Add void return type hint for MonologCollector::write()

    This would fix an issue who uses MonologCollector with Monolog v2.

    There is an issue when you try to use Bridge/MonologCollector because the abstract method signature has changed in Monolog v2. The diff: https://github.com/Seldaek/monolog/commit/06143b03e5c1598bfa6c6df65432010da0ecc28b#diff-d1d031ebe96084844fb53eb650bc404eR50

    However, this change is a bit tricky. Because Monolog in v2 has increased PHP dependency to ^7.2, also added those void return type hints. So this change could break things for people who uses MonologCollector with PHP version lower than 7.1.

    Reviewed by ekateiva at 2019-10-18 09:12
  • 6. highlight.pack.js won't respond

    After the last update of your package, I have the following problem. When I'm loading a random webpage (debug-bar is enabled), every time I receive the following message.

    A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.

    Script: http://doggy.dev/packages/maximebf/php-debugbar/vendor/highlightjs/highlight.pack.js:1

    Could you help me out with this issue?

    Thanks in advance.

    Reviewed by ghost at 2014-03-26 09:19
  • 7. Clear old storage automatically

    Would it be a good idea to clear the storage after a while? The collectors would keep on heaping up if you forget to do it by hand. I created a simple garbage collection method that runs every few requests that removes all files older then 24 hours. Would this be handy for all storages? See https://github.com/barryvdh/laravel-debugbar/commit/5aa061810042f432234ee062c7e2c01c9626cdc1

    Reviewed by barryvdh at 2014-02-04 09:22
  • 8. Add real usage option to memory collection

    The memory_get_usage and memory_get_peak_usage functions have a $real_usage parameter. Update the MemoryCollector and PDOCollector collectors to allow the user to choose which type of memory usage to gather.

    To recap, when $real_usage is set (and previously this was the hard-coded default), PHP returns the amount of memory allocated from the operating system by the PHP memory manager. This is typically done in large chunks of memory and is not very granular.

    When $real_usage is cleared, PHP returns the amount of memory the user’s application has actually allocated from the PHP memory manager.

    Clearing $real_usage has useful application especially for the PDOCollector. As an example, a query that returns only a few rows will often say that zero bytes were used when $real_usage is set. That’s because PHP was able to satisfy the memory requests from memory it had already allocated from the operating system. To contrast, the same query will show an expected few kilobytes of memory usage when $real_usage is set to false.

    Reviewed by james-johnston-thumbtack at 2017-03-06 02:36
  • 9. Class 'DebugBar\\StandardDebugBar' not found

    Hi,

    We are new to php DebugBar and never have been used any other php debugger. After searching many debugger, we have found php DebugBar and install it on our system as per instructions given on the website.

    We have installed this tool easily and no issue have been faced while installing. But when we merge the code (which is use to run DebugBar) in our simple test file then it giving us error that "Class 'DebugBar\StandardDebugBar' not found".

    We have searched a lot to resolve this issue but nothing got.

    Below is my code(test.php) where we are putting code:

    getJavascriptRenderer(); $debugbar["messages"]->addMessage("hello world!"); $arr = array('helo', 'world'); ?>

    My Project directory is: /projectname/test.php

    And DebugBar directory is: /projectname/DebugBar/

    Both the above things are in same project. DebugBar contains all the files downloaded at the the installing.

    Can anyone provide the solution for this issue? Solution will be appreciated.

    Reviewed by dhiru027 at 2014-11-18 11:57
  • 10. [Proposal] Chain exceptions

    Would it be nice to show chained exceptions? This patch just adds the previous exception, the same as any other exception. Maybe it could be formatted differently or made clear it was chaining, so this is just an example.

    Reviewed by barryvdh at 2014-03-07 13:24
  • 11. jQuery noConflict

    When people are using the package, they have to define whether or not they want to include the vendor files. I guess this is okay, but wouldn't it be easier to avoid conflicting vendors? Loading jQuery 2 times wouldn't be optimal, but it doesn't really matter that much in development I think.

    For jQuery, it should be possible to use jQuery.noConflict(true).

    PhpDebugBar.jQuery = $.noConflict(true);
    (function($) {
        //the debugbar code
    })(PhpDebugBar.jQuery);
    

    This would restore the original jQuery if possible and save it to a different variable (but that would be mapped to $ in the function. Only downside is that when you don't include the jquery from your vendors, it would remove all of jQuery, so you would always have to output jQuery, or do something like this (which doesn't seem really clean)

    PhpDebugBar.jQuery = $.noConflict(true);
    if(!jQuery){
        jQuery = PhpDebugBar.jQuery;
        $ = jQuery;
    }
    

    This would also prevent errors when older/newer jQuery versions are used (not that I encounted them, but could happen in the future)

    This would also make it more of a 'drop-in' profiler tool, without much configuration (at least for the Laravel version)

    Reviewed by barryvdh at 2013-09-19 12:57
  • 12. How to add a new Indicator?

    I've read the docs, but in my project what happens is, that the following code just adds an additional DebugBar:

    var debugbar = new PhpDebugBar.DebugBar();
    
    debugbar.createIndicator('dbhost', 'cogs', 'connected db', 'right');
    
    debugbar.setDataMap({
           'dbhost': ['time.duration_str', '0ms']
    });
    

    But of course I want to add the indicator to the existing bar.

    What am I missing?

    Reviewed by cswgr at 2022-05-10 08:02
  • 13. [Feature Request] Javascript events for how much margin was added to the body

    Issue is that we have other elements that have fixed positions at the bottom, so we either show them on top of debugbar (not nice looking) or we may miss those notifications when debugbar is open (again not cool due to missing info). Would be nice if we had an event we could observe that will tell us how much margin was added to the body to accommodate the debugbar size and add it accordingly to our own elements (for us it is some toast messages currently), or any other available info that we could use to adjust our layout when using it.

    Reviewed by TivoSoho at 2022-04-07 12:53
  • 14. Composer suggestion includes deprecated package

    Just a really small thing i've noticed in your composer.json:

    kriswallsmith/assetic is not maintained anymore. The new package should be assetic/framework from https://github.com/assetic-php/assetic

    https://github.com/maximebf/php-debugbar/blob/c2e310320b7751a959f1590bb76530abbcfd2ce6/composer.json#L34

    Keep up the great work. It helps alot!

    Reviewed by cloudchristoph at 2022-02-17 14:22
  • 15. Php8 1 fixes

    PHP 8.1 has depreciated mismatched return types on method overloads. I added appropriate return types when they were compatible with 7.1, and #[\ReturnTypeWillChange] where mixed types were returned, which are not compatible with 7.1.

    I also had to update the unit tests to work better under Windows and fixed more warnings from the unit tests. These fixes may actually be in another PR already.

    I also typed a few parameters in the modified files where it made sense to continue improving the code base. And I updated the composer.json file to support PHPUnit 8 and removed allowing PHP 8.2 and higher from working.

    This code now runs on my 8.1 server with no issues, but there may still be more 8.1 fixes needed, as my use case is probably pretty limited.

    Reviewed by phpfui at 2022-01-14 15:52
  • 16. on your website the include autoload is missing

    it took me hours to figure out what I have been doing wrong..

    // Require the Composer autoloader, if not already loaded require 'vendor/autoload.php';

    is missing on the example code on your website

    Reviewed by ipinky77 at 2021-10-05 18:48
Extends the Debug Bar plugin for the Sophi.io service
Extends the Debug Bar plugin for the Sophi.io service

Debug Bar for Sophi.io Extends the Debug Bar plugin for the Sophi.io service Requirements PHP 7.4+ WordPress 5.6+ Sophi.io 1.1.0+ Debug Bar 1.0+ Insta

May 19, 2022
Slim Framework Tracy Debugger Bar
 Slim Framework Tracy Debugger Bar

Slim Framework Tracy Debugger Bar configure it by mouse now in package: Panel Description Slim Framework - Slim Environment RAW data Slim Container RA

Feb 26, 2022
PHP Debug Console
PHP Debug Console

PHP Console A web console to try your PHP code into Creating a test file or using php's interactive mode can be a bit cumbersome to try random php sni

May 14, 2022
Php Debugger to run in terminal to debug your code easily.
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source lib to make a debug in php direct in terminal, without necessary configure an IDE. Th

Jan 12, 2022
Ray server is a beautiful, lightweight php app build on Laravel that helps you debug your app. It runs without installation on multiple platforms.
Ray server is a beautiful, lightweight php app build on Laravel that helps you debug your app. It runs without installation on multiple platforms.

RayServer is a beautiful, lightweight web server built on Laravel and VueJs that helps debugging your app. It runs without installation on multiple platforms.

May 16, 2022
Php Debugger to run in terminal to debug your code easily.
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source library that allows a developer to debug in php direct in terminal, without necessary

May 20, 2022
An elegant debug assistant for the Laravel framework.
An elegant debug assistant for the Laravel framework.

Introduction Laravel Telescope is an elegant debug assistant for the Laravel framework. Telescope provides insight into the requests coming into your

May 19, 2022
A simple Craft module, inspired by Mildly Geeky's "Kint", to debug Twig within your browser
A simple Craft module, inspired by Mildly Geeky's

A simple Craft module, inspired by Mildly Geeky's "Kint", to debug Twig within your browser

Feb 2, 2022
Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

PHP Console server library PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things u

May 19, 2022
PHP APM (Alternative PHP Monitor)

APM (Alternative PHP Monitor) APM (Alternative PHP Monitor) is a monitoring extension enabling native Application Performance Management (APM) for PHP

May 19, 2022
Zipkin PHP is the official PHP Tracer implementation for Zipkin

Zipkin PHP is the official PHP Tracer implementation for Zipkin, supported by the OpenZipkin community. Installation composer require openz

May 14, 2022
Xdebug — Step Debugger and Debugging Aid for PHP

Xdebug Xdebug is a debugging tool for PHP. It provides step-debugging and a whole range of development aids, such as stack traces, a code profiler, fe

May 25, 2022
Kint - a powerful and modern PHP debugging tool.
Kint - a powerful and modern PHP debugging tool.

Kint - debugging helper for PHP developers What am I looking at? At first glance Kint is just a pretty replacement for var_dump(), print_r() and debug

May 14, 2022
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

May 20, 2022
PHP Benchmarking framework
PHP Benchmarking framework

PHPBench is a benchmark runner for PHP analogous to PHPUnit but for performance rather than correctness. Features include: Revolutions: Repeat your co

May 22, 2022
The Interactive PHP Debugger

The interactive PHP debugger Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality

Apr 26, 2022
Dontbug is a reverse debugger for PHP
Dontbug is a reverse debugger for PHP

Dontbug Debugger Dontbug is a reverse debugger (aka time travel debugger) for PHP. It allows you to record the execution of PHP scripts (in command li

May 8, 2022
PCOV - CodeCoverage compatible driver for PHP

PCOV A self contained CodeCoverage compatible driver for PHP Requirements and Installation See INSTALL.md API /** * Shall start recording coverage in

May 6, 2022
Low-overhead sampling profiler for PHP 7+
Low-overhead sampling profiler for PHP 7+

phpspy phpspy is a low-overhead sampling profiler for PHP. For now, it works with Linux 3.2+ x86_64 non-ZTS PHP 7.0+ with CLI, Apache, and FPM SAPIs.

May 25, 2022