PHP Debugbar integration for Laravel
barryvdh/laravel-debugbar stats
- Downloads
- 64M
- Stars
- 15,580
- Open Issues
- 100
- Forks
- 1,548
Barryvdh Laravel Debugbar Package Summary
The Barryvdh Laravel Debugbar package integrates PHP Debug Bar with Laravel, providing a powerful and flexible way to add debugging capabilities directly into your Laravel applications. Ideal for development environments, this tool helps you monitor various aspects of your application without affecting production performance.
Key Features
- Multiple Data Collectors: Includes collectors for queries, routes, views, events, Laravel environment, request/response data, and more.
- Integration with Laravel: Seamlessly integrates with Laravel's service provider and uses facades for easier logging and message handling.
- Customizable: Enable or disable individual collectors, manage vendor files inclusion, and configure through Laravel's environment settings or directly in the config file.
- Runtime Control: Easily enable or disable the Debugbar during runtime via simple method calls.
- Storage and History: Stores data from requests for later analysis, accessible through a browser interface.
- Twig Support: Includes extensions for Twig to use Debugbar functions within templates.
Installation
Install via composer for development environments only to prevent potential data leakage and performance hits in production:
composer require barryvdh/laravel-debugbar --dev
Laravel's package auto-discovery handles the service provider linking. After installation, publish configuration and assets using:
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
For non-auto-discovery setups, manually add the service provider and facade in your config/app.php
.
Configuration
- Enable or disable Debugbar in your
.env
file usingDEBUGBAR_ENABLED
or directly in theconfig/debugbar.php
. - Customize data collectors, manage asset loading, and configure storage options through the published configuration file.
Usage
Utilize the Debugbar for logging, timing, and error handling:
Debugbar::info($object);Debugbar::error('Error!');Debugbar::startMeasure('render', 'Time for rendering');Debugbar::stopMeasure('render');
Debugbar supports conditional enabling/disabling, which can be adjusted during runtime:
\Debugbar::enable();\Debugbar::disable();
Security Note
Only use Debugbar in development environments or securely restricted areas of staging environments. Ensure it is disabled in production to prevent performance degradation and information exposure.
Additional Integration
For Lumen or Laravel Octane, specific configuration steps are required, detailed in the package documentation. Debugbar also supports integration with Twig through additional extensions, enhancing debugging capabilities within Twig templates.
In summary, the Laravel Debugbar by Barryvdh is an essential tool for developers looking to streamline their debugging processes efficiently, offering extensive customization and integration options tailored for Laravel applications.