Laravel Inspector, debugging and profiling tools for Web Artisans

Installs: 40 917

Dependents: 0

Suggesters: 0

Security: 0

Stars: 240

Watchers: 13

Forks: 16


v1.0.6 2017-07-31 22:39 UTC

This package is not auto-updated.

Last update: 2022-11-26 09:30:32 UTC


At a Glance

Messages Exceptions
idd() - Dump and die on steroids idd() SQLs page
Laravel Inspector as the default Exception renderer Timers and Timeline
Redirection API/Ajax calls
Using Postman REST client app laravel_inspector=dump parameter
Available Collectors Information about
MessageCollector User's messages and dumps
ExceptionCollector Exceptions
DBCollector Queries, including execution time and parameters binding
TimersCollector Timers and time stamps
RoutesCollector Application routes
RequestCollector Current Request
ResponseCollector Current Response
SessionCollector Session variables
ServerCollector $_SERVER dump
More to come...


This package was tested under PHP 5.6, PHP 7, Laravel 5.2 and Laravel 5.3-Dev

Installing the package via composer:

composer require lsrur/inspector

Next, add InspectorServiceProvider to the providers array in config/app.php:


And this Facade in the same configuration file:

'Inspector' => Lsrur\Inspector\Facade\Inspector::class,

For usage only during development and not during production, do not edit the config/app.php and add the following to your AppServiceProvider :

public function register()
  // ...
  if ($this->app->environment() == 'development') {
  // ...


In order to use Inspector as the default exceptions renderer, add the following line in the file app/Exceptions/Handler.php of your Laravel project:

public function render($request, Exception $exception)
    \Inspector::renderException($exception);	// <= THIS LINE
    return parent::render($request, $exception);

For usage only during development:

public function render($request, Exception $exception)
    if (\App::environment() == 'development')
    return parent::render($request, $exception);


Laravel inspector can be invoked using the Facade, the provided helper functions and a Blade directive:

//Using Facade

//Using the "inspector" helper function

// "li" is an alias of "inspector"

// "inspect" function makes an "Inspector::log($v)" for each passed argument
inspect($var1, $var2, $var3, ...);

// Dump and die using Laravel Inspector magic
idd($var1, $var2);

// Inside Blade

// samples
@li('log', 'My comment', $myVar)
@li(log, 'My comment', $myVar) //also works without command quotes

Laravel inspector will only be active if the config variable app.debug is true.
Anyway, you can temporarily turn Inspector off (just for the current request) with:



You can inspect objects and variables with the following methods, each of which has its own output format:

Method Description
log([string $description,] mixed $data) Outputs data with "log" format
info([string $description,] mixed $data) Outputs data with "info" format
error([string $description,] mixed $data) Outputs data with "error" format
warning([string $description,] mixed $data) Outputs data with "warning" format
success([string $description,] mixed $data) Outputs data with "success" format
table([string $description,] mixed $data) Outputs data inside a table


li()->log("MyData", $myData);
li()->table("clients", $myClientsCollection);

Additionally, you can use the "inspect" helper function to quickly inspect objects and variables.

inspect($var1, $var2, $var3,...);

Grouping Messages

Laravel Inspector allows you to group messages into nodes and subnodes:

		li()->error('oops', $errorCode);

In addition to the ability to group information, each group and subgroup excecution time will be measured and shown. If you forget to close a group, Laravel Inspector will automatically do it at the end of the script, but the excecution time for that group can not be taken.


Method Description
time(string $timerName) Starts a timer
timeEnd(string $timerName) Ends a timer
timeStamp(string $name) Adds a single marker to the timeline


// ...

li()->timeStamp('Elapsed time from LARAVEL_START here');


Laravel Inspector handles redirects smoothly; showing the collectors bag for both, the original and the target views.

Dump and die

The dd() method (or idd() helper) will dump the entire collectors bag and terminates the script:


// or simply

// adding last minute data
idd($var1, $var2,...)

As the rest of the package, this feature intelligently determines how will be the format of the output, even if the call was performed from CLI.

Another way to make an inspection, but without interrupting the flow of the request/response, is by adding the parameter laravel_inspector=dump to the URL:

Thus, Laravel Inspector wont be activated until the a terminable middleware is reached.


The function addException() will inspect our caught exceptions:

try {
} catch (Exception $e) {

Optionally, you can setup LI as the default exception renderer during development time (app.debug=true). Refer to the configuration to do so.

VIEW/AJAX/API requests, how it works

Laravel Inspector (LI) automatically detects the type of the request/response pair and determines the output format. If a View response is detected, the code needed to elegantly show the collected information in the browser console will be injected as a javascript into that view. Along with this, LI will also add a small piece of pure javascript code that serves as a generic http interceptor, which will examine subsequent AJAX calls looking for information injected by LI (this interceptor was tested under pure javascript, Angular 1.x ($http) and jQuery ($.ajax) and should work with any js framework). The interceptor also adds a header in each client AJAX call to let LI know that the interceptor is present. Then, from Laravel side, during an AJAX request or a JSON response, LI will send a script to be interpreted (and properly rendered in the browsers console) by the interceptor, OR a pure Json if that header is not present and then assuming that the request was sent from cURL, a REST client app or something else.

If you are developing, for example, an SPA and using Laravel only for the API but not to serve the web page/s, you can include the following code in your client app to take full advantage of all formatting features of Laravel Inspector.

(function(XHR) {
"use strict";

var send = XHR.prototype.send;

XHR.prototype.send = function(data) {
	var self = this;
	var oldOnReadyStateChange;
	var url = this._url;
	this.setRequestHeader('Laravel-Inspector', 'interceptor-present');
	function onReadyStateChange() {
		if(self.readyState == 4 /* complete */) {
			var response = JSON.parse(this.response);
			if (typeof response.LARAVEL_INSPECTOR !== 'undefined') {
				if(typeof response.LARAVEL_INSPECTOR === 'string')
				} else {
					console.log('LARAVEL INSPECTOR ', response);
		if(oldOnReadyStateChange) {
	if(!this.noIntercept) {            
		if(this.addEventListener) {
			this.addEventListener("readystatechange", onReadyStateChange, false);
		} else {
			oldOnReadyStateChange = this.onreadystatechange;
			this.onreadystatechange = onReadyStateChange;
	}, data);


Laravel Inspector is licensed under the MIT License.