Laravel Debugbar (Integrates PHP Debug Bar)

Last update: May 24, 2022

Laravel Debugbar

Unit Tests Packagist License Latest Stable Version Total Downloads

This is a package to integrate PHP Debug Bar with Laravel. It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel. It bootstraps some Collectors to work with Laravel and implements a couple custom DataCollectors, specific for Laravel. It is configured to display Redirects and (jQuery) Ajax Requests. (Shown in a dropdown) Read the documentation for more configuration options.

Debugbar 3.3 Screenshot

Note: Use the DebugBar only in development. It can slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors.

This package includes some custom collectors:

  • QueryCollector: Show all queries, including binding + timing
  • RouteCollector: Show information about the current Route.
  • ViewCollector: Show the currently loaded views. (Optionally: display the shared data)
  • EventsCollector: Show all events
  • LaravelCollector: Show the Laravel version and Environment. (disabled by default)
  • SymfonyRequestCollector: replaces the RequestCollector with more information about the request/response
  • LogsCollector: Show the latest log entries from the storage logs. (disabled by default)
  • FilesCollector: Show the files that are included/required by PHP. (disabled by default)
  • ConfigCollector: Display the values from the config files. (disabled by default)
  • CacheCollector: Display all cache events. (disabled by default)

Bootstraps the following collectors for Laravel:

  • LogCollector: Show all Log messages
  • SwiftMailCollector and SwiftLogCollector for Mail

And the default collectors:

  • PhpInfoCollector
  • MessagesCollector
  • TimeDataCollector (With Booting and Application timing)
  • MemoryCollector
  • ExceptionsCollector

It also provides a Facade interface for easy logging Messages, Exceptions and Time


Require this package with composer. It is recommended to only require the package for development.

composer require barryvdh/laravel-debugbar --dev

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

The Debugbar will be enabled when APP_DEBUG is true.

If you use a catch-all/fallback route, make sure you load the Debugbar ServiceProvider before your own App ServiceProviders.

Laravel without auto-discovery:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php


If you want to use the facade to log messages, add this to your facades in app.php:

'Debugbar' => Barryvdh\Debugbar\Facade::class,

The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config (debugbar.enabled) or by setting DEBUGBAR_ENABLED in your .env. See more options in config/debugbar.php You can also set in your config if you want to include/exclude the vendor files also (FontAwesome, Highlight.js and jQuery). If you already use them in your site, set it to false. You can also only display the js or css vendors, by setting it to 'js' or 'css'. (Highlight.js requires both css + js, so set to true for syntax highlighting)

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"


For Lumen, register a different Provider in bootstrap/app.php:

if (env('APP_DEBUG')) {

To change the configuration, copy the file to your config folder and enable it:



You can now add messages using the Facade (when added), using the PSR-3 levels (debug, info, notice, warning, error, critical, alert, emergency):

Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');

And start/stop timing:

Debugbar::startMeasure('render','Time for rendering');
Debugbar::addMeasure('now', LARAVEL_START, microtime(true));
Debugbar::measure('My long operation', function() {
    // Do something…

Or log exceptions:

try {
    throw new Exception('foobar');
} catch (Exception $e) {

There are also helper functions available for the most common calls:

// All arguments will be dumped as a debug message
debug($var1, $someString, $intValue, $object);

// `$collection->debug()` will return the collection and dump it as a debug message. Like `$collection->dump()`
collect([$var1, $someString])->debug();

start_measure('render','Time for rendering');
add_measure('now', LARAVEL_START, microtime(true));
measure('My long operation', function() {
    // Do something…

If you want you can add your own DataCollectors, through the Container or the Facade:

Debugbar::addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));
//Or via the App container:
$debugbar = App::make('debugbar');
$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));

By default, the Debugbar is injected just before </body>. If you want to inject the Debugbar yourself, set the config option 'inject' to false and use the renderer yourself and follow

$renderer = Debugbar::getJavascriptRenderer();

Note: Not using the auto-inject, will disable the Request information, because that is added After the response. You can add the default_request datacollector in the config as alternative.

Enabling/Disabling on run time

You can enable or disable the debugbar during run time.


NB. Once enabled, the collectors are added (and could produce extra overhead), so if you want to use the debugbar in production, disable in the config and only enable when needed.

Twig Integration

Laravel Debugbar comes with two Twig Extensions. These are tested with rcrowe/TwigBridge 0.6.x

Add the following extensions to your TwigBridge config/extensions.php (or register the extensions manually)


The Dump extension will replace the dump function to output variables using the DataFormatter. The Debug extension adds a debug() function which passes variables to the Message Collector, instead of showing it directly in the template. It dumps the arguments, or when empty; all context variables.

{{ debug() }}
{{ debug(user, categories) }}

The Stopwatch extension adds a stopwatch tag similar to the one in Symfony/Silex Twigbridge.

{% stopwatch "foo" %}
    …some things that gets timed
{% endstopwatch %}

  • 1. PhpDebugBar is not defined - Laravel 5.1

    Hi, I know that a similar issue has been solved before, but I tried to follow the same suggested procedures but none of them worked for me. I'm using Laravel 5.1 .

    I'm getting the following 404 not found errors :

    <http://my_website_url/_debugbar/assets/stylesheets?1436453519> <http://my_website_url/_debugbar/assets/javascript?1423122680>

    and <PhpDebugBar is not defined>

    I put debugbar first in the ServiceProviders and I don't have a catchall in my routes. The only thing I have in my routes is the following: <Route::get('/', '[email protected]');>

    Reviewed by omaromran at 2015-08-18 19:09
  • 2. Refused to get unsafe header "phpdebugbar"


    I'm currently in Chrome latest version (just checked it)

    As of this morning I'm getting two error in my console.

    • Refused to get unsafe header "phpdebugbar-id"
    • Refused to get unsafe header "phpdebugbar"

    I'm thinking this is not a specific debugbar notification so I tried Googling for it but no luck.

    I disabled the debugbar for testing purposes which results in no errors at all (obviously).

    Does anyone have a clue wat is going on?

    Reviewed by boywijnmaalen at 2015-08-10 09:23
  • 3. assets.css and assets.js not found

    Hi, I just updated to the latest laravel-debugbar and now I'm getting 404 Not Found errors when loading

    /_debugbar/assets.css?xxxxx /_debugbar/assets.js?xxxxx

    I can see that the routes are properly registered, but for some reason Nginx is not routing it correct. Could it be my Nginx config? Here is my config taken from the Server section below:

        location / {
            # URLs to attempt, including pretty ones.
            try_files   $uri $uri/ /index.php?$query_string;
        # Remove trailing slash to please routing system.
        if (!-d $request_filename) {
            rewrite     ^/(.+)/$ /$1 permanent;
        # PHP FPM configuration.
        location ~ \.php$ {
                fastcgi_pass                    unix:/var/run/php-fcgi.sock;
                fastcgi_index                   index.php;
                fastcgi_split_path_info         ^(.+\.php)(/.+)$;
                include                         /etc/nginx/fcgi.conf;
                fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # We don't need .ht files with nginx.
        location ~ /\.ht {
                deny all;
        # Set header expirations on per-project basis
        location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
                expires 365d;
    Reviewed by anthonywkchan at 2014-09-03 21:21
  • 4. REST API profiling

    Hi! I'm having an API built with laravel. And I need to do some profiling on it. It's the classic REST API that returns json. How can I profile it with debugbar?

    Reviewed by qstyler at 2015-01-06 13:27
  • 5. Notice: Trying to get property 'cookies' of non-object

    Debugbar: 3.2.8 Laravel: 5.7 and 5.8 and 6

    Debugbar is causing cookie/session problems when being injected via InjectDebugbar() on error pages.

    ErrorException/public/index.php in ? Notice: Trying to get property 'cookies' of non-object

    This occurs whenever a 404 error/page is returned. the 404 page is displayed, the debugbar is missing from it and our error tracking system reports this error.

    • Install Laravel
    • Install Debugbar
    • Install something like to track the errors
    • Navigate to a non-existent route
    • You'll get a 404, but with no debugbar
    • and will show a error of "Notice: Trying to get property 'cookies' of non-object"
    ErrorException: Notice: Trying to get property 'cookies' of non-object
    #35 /vendor/laravel/framework/src/Illuminate/Session/CookieSessionHandler.php(69): Illuminate\Session\CookieSessionHandler::read
    #34 /vendor/laravel/framework/src/Illuminate/Session/Store.php(97): Illuminate\Session\Store::readFromHandler
    #33 /vendor/laravel/framework/src/Illuminate/Session/Store.php(87): Illuminate\Session\Store::loadSession
    #32 /vendor/laravel/framework/src/Illuminate/Session/Store.php(71): Illuminate\Session\Store::start
    #31 /vendor/laravel/framework/src/Illuminate/Support/Manager.php(146): Illuminate\Support\Manager::__call
    #30 /vendor/barryvdh/laravel-debugbar/src/SymfonyHttpDriver.php(42): Barryvdh\Debugbar\SymfonyHttpDriver::isSessionStarted
    #29 /vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(446): DebugBar\DebugBar::initStackSession
    #28 /vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(359): DebugBar\DebugBar::hasStackedData
    #27 /vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php(984): DebugBar\JavascriptRenderer::render
    #26 /vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(862): Barryvdh\Debugbar\LaravelDebugbar::injectDebugbar
    #25 /vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(747): Barryvdh\Debugbar\LaravelDebugbar::modifyResponse
    #24 /vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(74): Barryvdh\Debugbar\Middleware\InjectDebugbar::handle
    #23 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #22 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #21 /vendor/fideloper/proxy/src/TrustProxies.php(57): Fideloper\Proxy\TrustProxies::handle
    #20 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #19 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #18 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
    #17 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #16 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #15 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
    #14 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #13 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #12 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle
    #11 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #10 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #9 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::handle
    #8 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #7 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #6 /vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Barryvdh\Cors\HandlePreflight::handle
    #5 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    #4 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}
    #3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline::then
    #2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
    #1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel::handle
    #0 /public/index.php(53): null
    Reviewed by SlyDave at 2019-09-17 09:50
  • 6. debugbar refreshes on each ajax call


    Our codebase has a heartbeat ajax call every X seconds. So we're doing quite some ajax call to be honest. (it is planned to move this to a socket, but we'll need to schedule that for next year probably)

    Anyway. On my local machine, I can easily click the "folder icon" in my laravel debugbar, and select which call I would like to see the details for. It works great. The same code deployed on an AWS instance however, automatically always updates my debugbar view to the latest ajax call which is pretty annoying, because it updates everything every X seconds, and I don't have time to check the queries for a specific call or whatever.

    Has anyone experienced this issue and/or found a solution? I have googled and searched the issues on here, but to no avail.

    Thanks very much!

    Reviewed by denjaland at 2017-07-01 06:23
  • 7. Debugbar::enable() does not seem to work!

    I have the below code in a middleware and disabling debug_bar (if i have it enabled by default) works fine! However if I try the opposite, meaning having the debug bar disabled by default and try to enable it on demand then id does not work.

    Any ideas?

    P.S. lavavel's own debug mode works fine like this! gets enable or disabled when i want!

        if ($request->has('disable_debug')) {
            \Config::set('app.debug', false);
        if ($request->has('enable_debug')) {
            \Config::set('app.debug', true);
    Reviewed by unitedworx at 2015-11-23 10:40
  • 8. Debugbar is not displaying in Laravel 5

    I thought this was a Laravel 5.0.16 issue, however I've tested with a fresh install of 5.0.1 with the same results as below. I have a few projects created I believe with 5.0.12, where the debugbar was working. They have been updated to 5.0.16 and still display the debugbar. However new projects are not showing the debugbar.

    Testing with a fresh install of Laravel 5.0.16 composer create-project laravel/laravel --prefer-dist composer require barryvdh/laravel-debugbar

    Added to config/app.php 'Barryvdh\Debugbar\ServiceProvider', 'Debugbar' => 'Barryvdh\Debugbar\Facade',

    php artisan vendor:publish successfully creates config/debugbar.php

    stat -c %a storage/ returns 777

    .env APP_ENV=local APP_DEBUG=true

    The Laravel 5 welcome screen is displayed, however the debugbar is not. Checking view source shows that the debugbar code has been added to the page. The following assets return a 404. /_debugbar/assets/stylesheets?1426726547 /_debugbar/assets/javascript?1426726547

    Reviewed by Daem0nX at 2015-03-19 02:09
  • 9. Debugbar Not Showing

    Issue Type

    • [x] Bug Report

    End User Info

    -- Laravel Version: 5.6.38

    -- PHP Version: 7.2.10

    -- Database Driver & Version: MariaDB 10.3.8

    -- Web Server Driver & Version: NGINX 1.15.0

    -- OS Driver and Version: Ubuntu 18.04.1


    • Installed using composer require barryvdh/laravel-debugbar
    • Published config using php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
    • Set .env APP_ENV=local APP_DEBUG=true
    • Set debugbar.php config enabled to true
    • Ran php artisan clear:all Clearing several common cache's ... Blade templates cached successfully! Route cache cleared! Routes cached successfully! Configuration cache cleared!
    • Cleared OPCache php artisan opcache:clear Opcode cache cleared

    I don't see debug bar in bottom of browser...

    Reviewed by HDVinnie at 2018-09-21 15:21
  • 10. Unable to view AJAX requests results


    I'm unable to get AJAX queries to properly report on 1.8.3.

    I have the following settings of interest in my config.php

    'include_vendors' => false,
    'capture_ajax' => true,

    Some information that is probably of interest to debugging this issue:

    • Provided jquery is 1.11.0
    • The request returns a phpdebugbar-id in the response header
    • A breakpoint in the bindToXHR method of the extended AjaxHandler.prototype will only trigger on setup. never appears to be called when $.ajax is called (by a third-party library).
    • Browser is chrome 39.0.2171.95 (64-bit)

    The application using laravel-debugbar also makes use of angular, for which we use the ng-phpdebugbar module in order to track $http requests. This works properly. I've also verified that it doesn't interfere with php-debugbar by disabling it completely.

    Let me know if any other information might be useful to debug this.


    Reviewed by tomzx at 2015-01-12 23:01
  • 11. Tabs not working.

    I started a new project with Laravel Debugbar and the tabs are not expanding up they act like there going to but don't. I've been using this for a while now and I've never had this problem till now. Thanks for any help.

    Reviewed by dragonfire1119 at 2014-08-08 17:55
  • 12. Update Querycollector with SQLite Explain support

    This adds support for SQLite EXPLAIN statement. There is no support for EXPLAIN QUERY PLAN yet, as this would require further adjustments to the package config.

    I'm not happy with adding HTML to the collector class, maybe we can find a better way of adding it to the widget?

    Regarding config changes, I would like to add an option that allows to set which kind of SQL EXPLAIN to use and change the output of explain accordingly.

    Reviewed by mikewink at 2022-05-19 20:47
  • 13. script tag content displayed as text.


    I got an issue - while debugbar works perfectly fine with my default layout, it get's f'd with the admin layout.

    It simply displays the contents of the