The debugging process in the programming world is usually tedious, not easy and take a lot of time. That's why there are many developers that focus on how to improve the development process on multiple technologies. In PHP, some people have become the idea of implementing such a debugging bar that the PHP developer can use to debug the code on the view without using
echo etc. Although many modern frameworks like Symfony, already include such an useful debugging bar (Symfony Profiler):
There are other like Laravel, Zend, Phalcon etc that doesn't offer such utility. That's why an independent library comes in handy in those cases, therefore we want to introduce you the PHP Debug Bar project.
What is PHP Debug Bar
The Debug Bar library allows you to integrate easily in any projects an useful debug bar that can display profiling data from any part of your application. It comes built-in with data collectors for standard PHP features and popular projects.
- Generic debug bar with no other dependencies.
- 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.
- Easily create your own collectors and their associated view in the bar.
- Save and re-open previous requests.
- Very well documented.
The library can be easily used an installed with composer using the following command:
composer require maximebf/debugbar
After its installation you will be able to include the classes of PHP Debug bar and implement the renderer in the view.
How to use?
Rendering is performed using the
Each panel is composed of a widget which is used to display the data from a data collector. Some common widgets are provided in the widgets.js file. The PhpDebugBar namespace is used for all objects and the only dependencies are jQuery and FontAwesome (css). FontAwesome is optional but is used to add nice icons. The main class is PhpDebugBar.DebugBar. It provides the infrastructure to manage tabs, indicators and datasets. When initialized, the DebugBar class adds itself to the <body> of the page. It is empty by default.
For a more detailed implementation, we recommend you to visit the demo source code in the repository that implements the debug bar.
How to contribute?
The project is open source under the MIT license, which means that you can report issues, create pull requests on the official repository.