Guide · Open source
How to use laravel-debugbar: install, configure and read the toolbar
Updated · written with AI from the project's own documentation and checked against our catalogue data
Laravel Debugbar is a package that adds a debug toolbar to your web pages while you develop. It wraps the PHP Debug Bar library and shows details about each request, such as database queries, loaded views, routes, events, logs and timing. This guide walks through installing it with Composer, turning it on and off, reading the toolbar, and keeping it away from anything public.
Quick start
- 1Check prerequisites. Confirm you have PHP, Composer and a Laravel application in a local development environment.
- 2Require the package as a dev dependency. Run composer require fruitcake/laravel-debugbar --dev so the package is installed only for development.
- 3Confirm APP_DEBUG is true. The Debugbar is enabled when APP_DEBUG is true and the environment is not production or testing.
- 4Publish the config (optional). Run php artisan vendor:publish --provider='Fruitcake\LaravelDebugbar\ServiceProvider' to copy the config into your project.
- 5Load a page and read the toolbar. Open a page in your browser and check the queries, route, views and timing shown in the bar.
- 6Turn off collectors if pages slow down. The README warns Debugbar can slow the app, so disable some collectors in the config when you see slowness.
What you need before you install Debugbar
Debugbar is a Laravel integration, so it only makes sense in a Laravel project. You need PHP and Composer on your machine, plus a working Laravel application.
- PHP and Composer installed
- A Laravel application
- A local development environment
Install laravel-debugbar with Composer
Require the package for development only. The README recommends installing it with the --dev flag so it stays out of production dependencies.
Laravel uses Package Auto-Discovery, so you do not need to add the ServiceProvider by hand. If you want a copy of the package config in your own project, publish it with the second command. The README marks this step as optional.
composer require fruitcake/laravel-debugbar --dev
php artisan vendor:publish --provider='Fruitcake\LaravelDebugbar\ServiceProvider'Control when the toolbar appears
The Debugbar is enabled when APP_DEBUG is true and the environment is not production or testing. You can turn it off in the config with debugbar.enabled, or set DEBUGBAR_ENABLED in your .env file. Other options live in config/debugbar.php.
You can also enable or disable it at run time with Debugbar::enable() and Debugbar::disable(). The README notes that once enabled, the collectors are added and can add overhead, so disable it in the config and enable it only when needed.
- debugbar.enabled or DEBUGBAR_ENABLED in .env controls the toolbar
- config/debugbar.php holds the other options
- Vendor assets (FontAwesome, Highlight.js and jQuery) can be included or excluded through config
\Debugbar::enable();\nDebugbar::disable();Read what the toolbar shows
The package includes several collectors. Some are on by default and some are disabled by default, so you may need to switch them on in the config. The most useful for slow pages and unexpected queries are the query and route collectors.
QueryCollector shows all queries with bindings and timing. RouteCollector shows information about the current route. ViewCollector lists the loaded views. EventsCollector lists events. LogsCollector, ConfigCollector and CacheCollector are disabled by default.
- QueryCollector: all queries, with bindings and timing
- RouteCollector: the current route
- ViewCollector: loaded views, optionally shared data
- EventsCollector: all events
- LogsCollector: latest storage log entries (disabled by default)
- ConfigCollector: config values (disabled by default)
- CacheCollector: cache events (disabled by default)
- FilesCollector: included PHP files (disabled by default)
Add your own messages and timers
You can log messages at PSR-3 levels, time parts of your code, and log exceptions. The helper functions cover the most common calls.
Use Debugbar::startMeasure and stopMeasure to time a block, or Debugbar::measure with a closure to time a function call. Debugbar::addThrowable records an exception.
Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::startMeasure('render','Time for rendering');
Debugbar::stopMeasure('render');
Debugbar::addThrowable($e);Keep Debugbar safe and check its storage
Debugbar stores previous requests, which you can open with the Browse button. By default this works only for requests from localhost or a private network. You can change this with debugbar.storage.open or DEBUGBAR_OPEN_STORAGE, or pass a callback that receives the Request object.
The README is clear that Debugbar should not be used on public websites because it leaks information from stored requests by design. Restrict access by IP if others can reach your development server.
- Only use it locally or behind an IP restriction
- Do not expose stored requests to other people
- Disable it in production; the force_allow_enable option exists but the README advises against installing it there at all
Use Debugbar with Twig through TwigBridge
If your project uses Twig through rcrowe/TwigBridge, the package includes Dump, Debug and Stopwatch extensions. The README says these are tested with TwigBridge 0.6.x. Add them to your TwigBridge extensions config, or register them manually.
{{ debug(user, categories) }}
{% stopwatch "foo" %}
...some things that gets timed
{% endstopwatch %}What people use it for
- Finding which database queries a slow page runs, with bindings and timing
- Checking which route, views and events a request used
- Debugging AJAX or Livewire requests, which the package shows in a dropdown
- Timing a block of code with startMeasure and stopMeasure
- Using debug helpers in Twig templates through TwigBridge
Frequently asked questions
How do I install laravel-debugbar?
Run composer require fruitcake/laravel-debugbar --dev in your Laravel project. Laravel's Package Auto-Discovery registers the ServiceProvider for you. Publishing the config with php artisan vendor:publish is optional.
Is laravel-debugbar free to use?
The package is licensed under MIT, as stated in the project's listing. Check the licence file in the repository for the full terms.
Can I use Debugbar in production?
No. The README says to use it only in development because it leaks information from stored requests by design. It also says it is highly recommended not to install it in production at all.
Why is my page slow with Debugbar on?
The README notes that Debugbar has to gather and render data, which can slow the app. Try disabling some collectors in the config to reduce the overhead.
What are the alternatives to laravel-debugbar?
Comparable projects include Laravel Telescope, Clockwork and the Symfony Profiler. This guide does not compare their features in detail, so check each project's documentation before choosing.
Does Debugbar work with Octane?
The README says Laravel Debugbar 4.x works out of the box with Octane and needs no extra config. If you upgrade from 3.x, remove the flush config for Debugbar in config/octane.php.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Laravel Debugbar suits Laravel developers who need to see queries, routes, views and events for a request on their own machine. It is not suitable for production sites or for apps that are already slow, and it is not a fit for projects that do not use Laravel. If you want a different profiler, compare Laravel Telescope, Clockwork and the Symfony Profiler.
Install options & downloads