1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 05:18:32 +01:00
php-debugbar/README.md

124 lines
4.5 KiB
Markdown
Raw Normal View History

2013-06-13 18:48:23 +08:00
# PHP Debug Bar
2013-06-08 01:32:10 +07:00
2021-06-22 10:04:06 +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) [![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!
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)
- [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)
- [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)
- [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)
- [October CMS](https://github.com/rainlab/debugbar-plugin)
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)
with the following command:
2013-06-13 18:48:23 +08: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
```PHP
<?php
2014-10-14 18:14:02 +02:00
// 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>
2013-10-25 16:43:00 -04:00
</html>
```
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`:
```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).
## 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`.
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.