2013-06-13 18:48:23 +08:00
# PHP Debug Bar
2013-06-08 01:32:10 +07:00
2024-08-01 09:28:30 -05:00
[![Latest Stable Version ](https://img.shields.io/packagist/v/maximebf/debugbar?label=Stable )](https://packagist.org/packages/maximebf/debugbar) [![Total Downloads ](https://img.shields.io/packagist/dt/maximebf/debugbar?label=Downloads )](https://packagist.org/packages/maximebf/debugbar) [![License ](https://img.shields.io/badge/Licence-MIT-4d9283 )](https://packagist.org/packages/maximebf/debugbar) [![Tests ](https://github.com/maximebf/php-debugbar/actions/workflows/run-tests.yml/badge.svg )](https://github.com/maximebf/php-debugbar/actions/workflows/run-tests.yml)
2013-08-14 22:36:03 +10:00
2013-06-13 18:48:23 +08:00
Displays a debug bar in the browser with information from php.
No more `var_dump()` in your code!
2024-10-29 14:54:29 +01:00
> **Note: Debug Bar is for development use only. Never install this on websites that are publicly accessible.**
2013-06-19 13:15:46 +09:00
![Screenshot ](https://raw.github.com/maximebf/php-debugbar/master/docs/screenshot.png )
2013-06-13 18:48:23 +08:00
**Features:**
2013-08-17 12:47:50 +10:00
- Generic debug bar
2013-06-13 18:48:23 +08:00
- 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
2013-09-05 15:18:55 +02:00
- Save and re-open previous requests
2013-08-13 12:29:40 +10:00
- [Very well documented ](http://phpdebugbar.com/docs )
2013-06-13 18:48:23 +08:00
2013-08-13 12:29:40 +10:00
Includes collectors for:
- [PDO ](http://php.net/manual/en/book.pdo.php )
- [CacheCache ](http://maximebf.github.io/CacheCache/ )
- [Doctrine ](http://doctrine-project.org )
- [Monolog ](https://github.com/Seldaek/monolog )
- [Propel ](http://propelorm.org/ )
- [Slim ](http://slimframework.com )
2023-09-08 17:00:50 -05:00
- [Symfony Mailer ](https://symfony.com/doc/current/mailer.html )
2013-08-13 12:29:40 +10:00
- [Swift Mailer ](http://swiftmailer.org/ )
2023-08-18 20:38:24 +03:00
- [Twig ](http://twig.symfony.com/ )
2013-08-13 12:29:40 +10:00
Checkout the [demo ](https://github.com/maximebf/php-debugbar/tree/master/demo ) for
examples and [phpdebugbar.com ](http://phpdebugbar.com ) for a live example.
2013-06-13 18:48:23 +08:00
2013-09-05 15:18:55 +02:00
Integrations with other frameworks:
2013-09-15 19:44:40 +02:00
- [Laravel ](https://github.com/barryvdh/laravel-debugbar )
2013-09-15 11:29:33 -04:00
- [Atomik ](http://atomikframework.com/docs/error-log-debug.html#debug-bar )
2013-09-15 19:44:40 +02:00
- [XOOPS ](http://xoops.org/modules/news/article.php?storyid=6538 )
2014-03-13 22:55:01 +01:00
- [Zend Framework 2 ](https://github.com/snapshotpl/ZfSnapPhpDebugBar )
2015-03-11 17:15:10 +08:00
- [Phalcon ](https://github.com/snowair/phalcon-debugbar )
2016-08-09 16:07:21 +02:00
- [SilverStripe ](https://github.com/lekoala/silverstripe-debugbar )
2016-08-28 09:57:48 -06:00
- [Grav CMS ](https://getgrav.org )
2018-04-09 14:22:09 +02:00
- [TYPO3 ](https://github.com/Konafets/typo3_debugbar )
2021-03-10 12:21:49 +01:00
- [Joomla ](https://github.com/joomla/joomla-cms/blob/4.0-dev/plugins/system/debug/debug.php )
2021-06-19 19:07:37 +02:00
- [Drupal ](https://www.drupal.org/project/debugbar )
2021-12-16 00:53:16 +11:00
- [October CMS ](https://github.com/rainlab/debugbar-plugin )
2024-07-02 10:24:16 +03:00
- Framework-agnostic middleware and PSR-7 with [php-middleware/phpdebugbar ](https://github.com/php-middleware/phpdebugbar )
- [Dotkernel Frontend Application ](https://github.com/dotkernel/dot-debugbar )
2015-09-22 21:20:58 +02:00
2013-09-05 15:18:55 +02:00
*(drop me a message or submit a PR to add your DebugBar related project here)*
2013-06-13 18:48:23 +08:00
## Installation
2013-08-17 12:47:50 +10:00
The best way to install DebugBar is using [Composer ](http://getcomposer.org )
2014-10-14 10:28:21 +02:00
with the following command:
2013-06-13 18:48:23 +08:00
2024-12-09 09:01:58 -06:00
```bash
composer require maximebf/debugbar --dev
```
2013-06-13 18:48:23 +08:00
## Quick start
2013-08-16 00:52:32 +01:00
DebugBar is very easy to use and you can add it to any of your projects in no time.
2013-06-13 18:48:23 +08:00
The easiest way is using the `render()` functions
2013-08-28 14:09:50 +02:00
```PHP
< ?php
2014-10-14 18:14:02 +02:00
// Require the Composer autoloader, if not already loaded
require 'vendor/autoload.php';
2013-08-28 14:09:50 +02:00
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 >
2013-10-25 16:43:00 -04:00
< / html >
2013-08-28 14:09:50 +02:00
```
2013-06-13 18:48:23 +08:00
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` :
2013-08-28 14:09:50 +02:00
```PHP
$debugbar["messages"]->addMessage("hello world!");
```
2013-06-13 18:48:23 +08:00
2013-08-13 12:29:40 +10:00
`StandardDebugBar` activates the following collectors:
2013-06-13 18:48:23 +08:00
- `MemoryCollector` (*memory*)
- `MessagesCollector` (*messages*)
- `PhpInfoCollector` (*php*)
- `RequestDataCollector` (*request*)
- `TimeDataCollector` (*time*)
2013-06-19 13:15:46 +09:00
- `ExceptionsCollector` (*exceptions*)
2013-06-13 18:48:23 +08:00
2013-06-20 12:08:50 +09:00
Learn more about DebugBar in the [docs ](http://phpdebugbar.com/docs ).
2024-03-30 08:50:08 +01:00
## Demo
To run the demo, clone this repository and start the Built-In PHP webserver from the root:
```
php -S localhost:8000
```
2024-03-31 20:14:48 +02:00
Then visit http://localhost:8000/demo/
## Testing
To test, run `php vendor/bin/phpunit` .
2024-06-10 11:17:33 +02:00
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.