All Projects → barryvdh → Laravel Debugbar

barryvdh / Laravel Debugbar

Licence: mit
Laravel Debugbar (Integrates PHP Debug Bar)

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Laravel Debugbar

Daybydaycrm
DaybydayCRM an open-source CRM, to help you keep track of your daily workflow.
Stars: ✭ 1,856 (-86.24%)
Mutual labels:  hacktoberfest, laravel
Novapackages
Stars: ✭ 169 (-98.75%)
Mutual labels:  hacktoberfest, laravel
Simple Qrcode
An easy-to-use PHP QrCode generator with first-party support for Laravel.
Stars: ✭ 1,923 (-85.74%)
Mutual labels:  hacktoberfest, laravel
Voyager
Voyager - The Missing Laravel Admin
Stars: ✭ 10,801 (-19.9%)
Mutual labels:  hacktoberfest, laravel
Laravelresources
Speed Up package development for Laravel Apps with API's
Stars: ✭ 152 (-98.87%)
Mutual labels:  hacktoberfest, laravel
Oc Mall Plugin
🏪 E-commerce solution for October CMS
Stars: ✭ 128 (-99.05%)
Mutual labels:  hacktoberfest, laravel
Ignition
A beautiful error page for Laravel apps
Stars: ✭ 1,885 (-86.02%)
Mutual labels:  hacktoberfest, laravel
Goodwork
Self hosted project management and collaboration tool powered by TALL stack
Stars: ✭ 1,730 (-87.17%)
Mutual labels:  hacktoberfest, laravel
Has Parameters
A trait that allows you to pass arguments to Laravel middleware in a more PHP'ish way.
Stars: ✭ 149 (-98.9%)
Mutual labels:  hacktoberfest, laravel
Laravel Ide Helper
Laravel IDE Helper
Stars: ✭ 11,893 (-11.81%)
Mutual labels:  hacktoberfest, laravel
Onramp
Easing the onramp for new or non-PHP developers to become Laravel devs.
Stars: ✭ 123 (-99.09%)
Mutual labels:  hacktoberfest, laravel
Bdgt
Big finance tools in a small package
Stars: ✭ 159 (-98.82%)
Mutual labels:  hacktoberfest, laravel
Laravel Mail Editor
MailEclipse ⚡ Laravel Mailable Editor!
Stars: ✭ 1,714 (-87.29%)
Mutual labels:  hacktoberfest, laravel
Health
Laravel Health Panel
Stars: ✭ 1,774 (-86.84%)
Mutual labels:  hacktoberfest, laravel
Facebook
📨 Facebook Notifications Channel for Laravel
Stars: ✭ 120 (-99.11%)
Mutual labels:  hacktoberfest, laravel
Jigsaw
Simple static sites with Laravel’s Blade.
Stars: ✭ 1,823 (-86.48%)
Mutual labels:  hacktoberfest, laravel
Laravel Api Boilerplate
A Boilerplate Project For Laravel API's (NOT MAINTAINED)
Stars: ✭ 113 (-99.16%)
Mutual labels:  hacktoberfest, laravel
Collector Intellij
A PhpStorm plugin for refactoring to collections
Stars: ✭ 114 (-99.15%)
Mutual labels:  hacktoberfest, laravel
Pipedrive
Complete Pipedrive API client for PHP
Stars: ✭ 138 (-98.98%)
Mutual labels:  hacktoberfest, laravel
Symposium
Management of proposals, bios, photos, etc. for conference speakers.
Stars: ✭ 157 (-98.84%)
Mutual labels:  hacktoberfest, laravel

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 (Debugbar) for easy logging Messages, Exceptions and Time

Installation

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

Barryvdh\Debugbar\ServiceProvider::class,

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

'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::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"

Laravel with Octane:

Make sure to add LaravelDebugbar to your flush list in config/octane.php.

    'flush' => [
        \Barryvdh\Debugbar\LaravelDebugbar::class,
    ],

Lumen:

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

if (env('APP_DEBUG')) {
 $app->register(Barryvdh\Debugbar\LumenServiceProvider::class);
}

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

$app->configure('debugbar');

Usage

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

Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');

And start/stop timing:

Debugbar::startMeasure('render','Time for rendering');
Debugbar::stopMeasure('render');
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) {
    Debugbar::addThrowable($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');
stop_measure('render');
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 http://phpdebugbar.com/docs/rendering.html

$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.

\Debugbar::enable();
\Debugbar::disable();

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)

'Barryvdh\Debugbar\Twig\Extension\Debug',
'Barryvdh\Debugbar\Twig\Extension\Dump',
'Barryvdh\Debugbar\Twig\Extension\Stopwatch',

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 %}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].