PHP Debugbar integration for Laravel

barryvdh/laravel-debugbar image

barryvdh/laravel-debugbar stats

Downloads
64M
Stars
15,580
Open Issues
100
Forks
1,548

View on GitHub →

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 using DEBUGBAR_ENABLED or directly in the config/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.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Barryvdh Laravel Debugbar Related Articles

Laravel Debugbar Gets a Big UI Update image

Laravel Debugbar Gets a Big UI Update

Read article
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Join the Mastering Laravel community logo

Join the Mastering Laravel community

Connect with experienced developers in a friendly, noise-free environment. Get insights, share ideas, and find support for your coding challenges. Join us today and elevate your Laravel skills!

Join the Mastering Laravel community
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit