2013-06-13 18:48:23 +08:00
|
|
|
# PHP Debug Bar
|
2013-06-08 01:32:10 +07:00
|
|
|
|
2014-10-17 11:11:20 +02:00
|
|
|
[![Latest Stable Version](https://poser.pugx.org/maximebf/debugbar/v/stable.png)](https://packagist.org/packages/maximebf/debugbar) [![Total Downloads](https://poser.pugx.org/maximebf/debugbar/downloads.svg)](https://packagist.org/packages/maximebf/debugbar) [![License](https://poser.pugx.org/maximebf/debugbar/license.svg)](https://packagist.org/packages/maximebf/debugbar) [![Build Status](https://travis-ci.org/maximebf/php-debugbar.png?branch=master)](https://travis-ci.org/maximebf/php-debugbar)
|
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!
|
|
|
|
|
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)
|
|
|
|
- [Swift Mailer](http://swiftmailer.org/)
|
|
|
|
- [Twig](http://twig.sensiolabs.org/)
|
|
|
|
|
|
|
|
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)
|
2015-10-19 21:53:27 +02:00
|
|
|
- Framework-agnostic middleware and PSR-7 with [php-middleware/phpdebugbar](https://github.com/php-middleware/phpdebugbar).
|
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
|
|
|
|
2014-10-14 10:28:21 +02:00
|
|
|
```composer require maximebf/debugbar```
|
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).
|