Top Related Projects
Debug bar for PHP
Provides mechanisms for walking through any arbitrary PHP variable
PHP errors for cool kids
Debugbar for Laravel (Integrates PHP Debug Bar)
Clockwork - php dev tools in your browser - server-side component
Quick Overview
PHP DebugBar is a powerful debugging tool for PHP applications. It provides a customizable debug bar that displays various information about your application's execution, including performance metrics, database queries, and custom data. This library is designed to help developers identify and resolve issues more efficiently during development.
Pros
- Highly customizable with a wide range of built-in collectors and data displays
- Easy integration with popular PHP frameworks like Laravel, Symfony, and Slim
- Supports both web and console applications
- Extensible architecture allowing for custom collectors and data displays
Cons
- Can impact performance when enabled in production environments
- Requires additional configuration for optimal use with some frameworks
- May expose sensitive information if not properly secured in production
- Learning curve for advanced customization and creating custom collectors
Code Examples
- Basic usage:
use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
// Add this to your HTML <head>
echo $debugbarRenderer->renderHead();
// Add this at the end of your HTML <body>
echo $debugbarRenderer->render();
- Adding custom messages:
$debugbar['messages']->addMessage('Hello World!');
$debugbar['messages']->addMessage($someVariable, 'Variable Contents');
- Measuring execution time:
$debugbar['time']->startMeasure('render', 'Time for rendering');
// ... your code here ...
$debugbar['time']->stopMeasure('render');
- Adding custom data:
$debugbar->addCollector(new DebugBar\DataCollector\ConfigCollector($configArray));
Getting Started
-
Install PHP DebugBar using Composer:
composer require maximebf/debugbar
-
In your PHP script, initialize the DebugBar:
use DebugBar\StandardDebugBar; $debugbar = new StandardDebugBar(); $debugbarRenderer = $debugbar->getJavascriptRenderer();
-
Add the following to your HTML
<head>
:echo $debugbarRenderer->renderHead();
-
At the end of your HTML
<body>
, add:echo $debugbarRenderer->render();
-
Start using the DebugBar in your code:
$debugbar['messages']->addMessage('Debug information');
Competitor Comparisons
Debug bar for PHP
Pros of php-debugbar
- Widely used and well-maintained debugging tool for PHP applications
- Extensive features for performance monitoring and error tracking
- Integrates seamlessly with popular PHP frameworks
Cons of php-debugbar
- May have a slight performance impact when enabled in production
- Requires manual configuration for some advanced features
- Learning curve for new users to fully utilize all capabilities
Code Comparison
Both repositories are the same, so there's no code comparison to make. Here's a sample of how to initialize php-debugbar:
use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
// Add this to your view
echo $debugbarRenderer->renderHead();
echo $debugbarRenderer->render();
Summary
Since both repositories mentioned in the prompt are identical (php-debugbar/php-debugbar), there are no differences to compare. The php-debugbar project is a popular debugging tool for PHP applications, offering robust features for performance monitoring and error tracking. While it may have a slight performance impact and require some configuration, its benefits in development and debugging often outweigh these minor drawbacks.
Provides mechanisms for walking through any arbitrary PHP variable
Pros of var-dumper
- Lightweight and focused on variable dumping and debugging
- Integrates seamlessly with Symfony framework and other Symfony components
- Provides advanced features like syntax highlighting and clickable references
Cons of var-dumper
- Limited to variable dumping and doesn't offer a full debugging toolbar
- May require additional setup for non-Symfony projects
- Less visual feedback compared to php-debugbar's graphical interface
Code Comparison
var-dumper:
use Symfony\Component\VarDumper\VarDumper;
$var = [1, 2, 3];
VarDumper::dump($var);
php-debugbar:
use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
$debugbar["messages"]->addMessage("hello world!");
Summary
var-dumper is a lightweight tool focused on variable dumping with advanced features, while php-debugbar provides a more comprehensive debugging toolbar. var-dumper integrates well with Symfony projects but may require additional setup for others. php-debugbar offers a more visual approach to debugging with its graphical interface. The choice between the two depends on the specific project requirements and the developer's preference for debugging style.
PHP errors for cool kids
Pros of Whoops
- Lightweight and focused on error handling
- Provides a clean, interactive interface for debugging errors
- Easy to integrate into existing projects
Cons of Whoops
- Limited to error handling and doesn't provide general debugging tools
- May require additional setup for framework-specific integrations
Code Comparison
Whoops:
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
PHP DebugBar:
$debugbar = new DebugBar\StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
Key Differences
- Whoops focuses on error handling and provides a detailed error page
- PHP DebugBar offers a broader range of debugging tools, including performance metrics and variable inspection
- Whoops is more suitable for quick error debugging, while PHP DebugBar is better for ongoing development and performance monitoring
Use Cases
- Whoops: Ideal for projects requiring detailed error reporting and stack traces
- PHP DebugBar: Better suited for complex applications needing comprehensive debugging and profiling tools
Integration
- Whoops is generally easier to integrate, especially in smaller projects
- PHP DebugBar may require more setup but offers more extensive features for larger applications
Debugbar for Laravel (Integrates PHP Debug Bar)
Pros of laravel-debugbar
- Seamless integration with Laravel framework
- Tailored for Laravel-specific features and performance metrics
- Automatic collection of Laravel-specific data (routes, views, etc.)
Cons of laravel-debugbar
- Limited to Laravel applications, not suitable for other PHP projects
- May have a slightly higher performance overhead due to Laravel-specific features
- Requires Laravel framework as a dependency
Code Comparison
php-debugbar:
$debugbar = new DebugBar();
$debugbar->addCollector(new MessagesCollector());
$debugbar->addCollector(new PhpInfoCollector());
$debugbar->addCollector(new RequestDataCollector());
$renderer = $debugbar->getJavascriptRenderer();
laravel-debugbar:
// In config/app.php
'providers' => [
// ...
Barryvdh\Debugbar\ServiceProvider::class,
],
'aliases' => [
// ...
'Debugbar' => Barryvdh\Debugbar\Facade::class,
],
The php-debugbar requires manual setup and configuration, while laravel-debugbar integrates seamlessly with Laravel's service provider and facade system, making it easier to use in Laravel applications but limiting its flexibility for non-Laravel projects.
Clockwork - php dev tools in your browser - server-side component
Pros of Clockwork
- Lightweight and less intrusive, with minimal impact on application performance
- Provides a clean, modern interface with a focus on simplicity and ease of use
- Offers a standalone desktop application for viewing debug data
Cons of Clockwork
- Less extensive feature set compared to PHP Debug Bar
- May require additional setup for certain frameworks or environments
- Limited customization options for the debug interface
Code Comparison
Clockwork:
use Clockwork\Support\Clockwork;
Clockwork::info('User logged in');
Clockwork::startEvent('long-operation', 'Long running operation');
// ... operation code ...
Clockwork::endEvent('long-operation');
PHP Debug Bar:
$debugbar = new DebugBar\StandardDebugBar();
$debugbar['messages']->addMessage('User logged in');
$debugbar['time']->startMeasure('long-operation', 'Long running operation');
// ... operation code ...
$debugbar['time']->stopMeasure('long-operation');
Both Clockwork and PHP Debug Bar are powerful debugging tools for PHP applications. Clockwork focuses on simplicity and performance, while PHP Debug Bar offers a more comprehensive set of features and greater customization options. The choice between the two depends on the specific needs of the project and developer preferences.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PHP Debug Bar
Displays a debug bar in the browser with information from php.
No more var_dump()
in your code!
Note: Debug Bar is for development use only. Never install this on websites that are publicly accessible.
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:
- Laravel
- Atomik
- XOOPS
- Zend Framework 2
- Phalcon
- SilverStripe
- Grav CMS
- TYPO3
- Joomla
- Drupal
- October CMS
- Framework-agnostic middleware and PSR-7 with php-middleware/phpdebugbar
- Dotkernel Frontend Application
(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 --dev php-debugbar/php-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.
Demo
To run the demo, clone this repository and start the Built-In PHP webserver from the root:
php -S localhost:8000
Then visit http://localhost:8000/demo/
Testing
To test, run php vendor/bin/phpunit
.
To debug Browser tests, you can run PANTHER_NO_HEADLESS=1 vendor/bin/phpunit --debug
. Run vendor/bin/bdi detect drivers
to download the latest drivers.
Top Related Projects
Debug bar for PHP
Provides mechanisms for walking through any arbitrary PHP variable
PHP errors for cool kids
Debugbar for Laravel (Integrates PHP Debug Bar)
Clockwork - php dev tools in your browser - server-side component
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot