Debug bar for PHP

Overview

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.

Comments
  • If body already has padding-bottom set, it's overwritten

    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?

    opened by focalstrategy 34
  • setDumpHeader error after upgrading symfony/var-dumper to v5.3.4

    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?

    opened by joostvanhoof 12
  • FIX PHP 5.4 compat for using function return value in write context

    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

    opened by robbieaverill 12
  • Highlight duplicate SQL queries.

    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.

    opened by joshuajabbour 12
  • Add void return type hint for MonologCollector::write()

    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.

    opened by ekateiva 11
  • highlight.pack.js won't respond

    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.

    opened by ghost 11
  • Clear old storage automatically

    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

    opened by barryvdh 11
  • Add real usage option to memory collection

    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.

    opened by james-johnston-thumbtack 9
  • Class 'DebugBar\\StandardDebugBar' not found

    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.

    opened by dhiru027 9
  • [Proposal] Chain exceptions

    [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.

    opened by barryvdh 9
  • jQuery noConflict

    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)

    opened by barryvdh 9
  • Error when using MonologCollector with monolog/monolog 3.2

    Error when using MonologCollector with monolog/monolog 3.2

    Hello

    I have tried using the Monolog Collector with version 3.0 and up of monolog. They changed of the "write" method, it no longer takes an array as a parameter. I solved the problem at home with an overload but if you want I can send you a PR

    See https://github.com/Seldaek/monolog/blob/3.0.0-RC1/src/Monolog/Handler/AbstractProcessingHandler.php abstract protected function write(LogRecord $record): void;

    opened by mimou78 1
  • Forcing display block to some css classes - to prevent mess with user defined css

    Forcing display block to some css classes - to prevent mess with user defined css

    to prevent big mess with user defined css, you could add display:block; in css files.

    For example here : https://github.com/maximebf/php-debugbar/blob/master/src/DebugBar/Resources/widgets.css#L142

     dl.phpdebugbar-widgets-kvlist dd {
        margin-left: 160px;
        padding: 5px;
        border-top: 1px solid #eee;
        cursor: pointer;
        min-height: 17px;
        display:block;
      }
    
    opened by simogeo 0
  • > Yes @Tsdjimmy : I recently upgraded my PHP version from PHP7 to PHP8.. What is its solution..?

    > Yes @Tsdjimmy : I recently upgraded my PHP version from PHP7 to PHP8.. What is its solution..?

    Yes @Tsdjimmy : I recently upgraded my PHP version from PHP7 to PHP8.. What is its solution..? **previous update composer Run composer update. Let me know if it worked.

    Originally posted by @Tsdjimmy in https://github.com/maximebf/php-debugbar/issues/482#issuecomment-1005732455

    opened by rokefeler 0
  • How to add a new Indicator?

    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?

    opened by cswgr 0
  • [Feature Request] Javascript events for how much margin was added to the body

    [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.

    opened by TivoSoho 0
  • Composer suggestion includes deprecated package

    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!

    opened by cloudchristoph 0
Releases(v1.18.1)
Owner
Maxime Bouroumeau-Fuseau
Maxime Bouroumeau-Fuseau
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

10up 2 Jun 22, 2022
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

null 72 Aug 29, 2022
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

Jordi Boggiano 523 Nov 7, 2022
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

Renato Cassino 190 Dec 3, 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.

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

Pavel Buchnev 310 Jan 2, 2023
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

Renato Cassino 190 Dec 3, 2022
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

The Laravel Framework 4.4k Dec 27, 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 "Kint", to debug Twig within your browser

TrendyMinds 4 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

Sergey 1.4k Dec 25, 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

Patrick Allaert 310 Dec 4, 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

Open Zipkin 250 Nov 12, 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

Xdebug 2.8k Jan 3, 2023
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

null 2.7k Dec 25, 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 - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
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

PHPBench 1.7k Jan 2, 2023
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

Joe Watkins 841 Oct 9, 2022
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

Sidharth Kshatriya 709 Dec 30, 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

Joe Watkins 613 Dec 21, 2022
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.

Adam 1.3k Dec 24, 2022