Connect your Laravel application with Inspector.

Server requirements

  • PHP >= 7.2

  • Laravel >= 5.5

To verify what version of PHP is installed on your server run this command in your terminal: php -v

To know what is the Laravel version behind your application run this command in your application's main directory: php artisan --version

Clear the Laravel configuration

Before installing the package you should clear your Laravel configuration to avoid unexpected error loading the default package config file.

Run the command below to clear your cached configuration:

php artisan config:clear


Type the command below in your terminal to install the latest version of the package:

composer require inspector-apm/inspector-laravel

For Lumen

If your application is based on Lumen you need to manually register the InspectorServiceProvider:


Configure the Ingestion Key

Get a new Ingestion Key by signing up for Inspector ( and creating a new application.

Put the Inspector Ingestion Key in your environment file:


Test everything is working

Execute the test command to check if your app can send data to inspector correctly:

php artisan inspector:test

Go to to explore your data.

By default Inspector will monitor everything executed in background:

  • Queued Jobs

  • Artisan commands

  • Unhandled Exceptions

If you want learn more about background jobs monitoring take a look on our article:

Go the Http Request Monitoring section to understand how to trace your application when it's executed due to an incoming http request.

Reporting Out Of Memory Errors

When your app runs out of memory it's needed to temporary increase the PHP memory limit to ensure inspector can report the current transaction. To do this, a “bootstrapper” class must be registered in both the app/Http/Kernel.php and app/Console/Kernel.php files:

protected function bootstrappers()
return array_merge(

The OutOfMemoryBootstrapper must be the first registered bootstrapper, or it may not be called before the out of memory exception crashes your app.

Access the Inspector instance

The current Inspector instance is binded in the Laravel service container. In your controller, you can type-hint an argument with the Inspector's class name.

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Inspector\Laravel\Inspector;
class HomeController extends Controller
* Show the application dashboard.
* @return \Illuminate\Contracts\Support\Renderable
public function index(Inspector $inspector)
return view('home');

You can also get the current Inspector instance using the Facade or the helper function:

* Using the Facade
\Inspector\Laravel\Facades\Inspector::addSegment(function () {
// Do something
}, 'label');
* Using the helper function
inspector()->addSegment(function () {
// Do something
}, 'label');