Inspector logo


Build Status Latest Stable Version


Run the composer command in your terminal:

composer require inspector-apm/inspector-laravel

Configure the API key

First put the Inspector API key in your environment file:


Get a fresh API key by signing up for Inspector ( and creating a new project.

By default Inspector will report:

  • Queued Jobs execution
  • Artisan commands
  • Unhandled Exceptions

Test everything is working

Create a test route using the code below:

Route::get('test', function () {
    throw new \Exception('First Exception detected'));

Open this route in you browser to test connection between your app and Inspection API.

Monitor Web Requests

To activate web requests inspection, you can use the Inspector middleware WebRequestMonitoringso you are free to decide which routes need to be monitored based on your routes configuration or on your personal monitoring preferences.

Attach the middleware in the Http\Kernel class:

use Inspector\Laravel\Middleware\WebRequestMonitoring;

 * The application's route middleware groups.
 * @var  array
protected $middlewareGroups = [
    'web' => [

    'api' => [

Report Errors & Exceptions manually

By default, every unhandled exception fired in your Laravel app will be reported automatically to be sure you're alerted for unpredictable errors in real time.

If your code fires an exception of which you want be aware, but you don't want to block the execution:

use Inspector\Laravel\Facades\Inspector;

try {

    // Your dangerous code...

} catch(LogicException $exception) {
    // Report an exception intentionally to collect diagnostics data

If something goes wrong in your code you will be alerted in real time in your inbox to take a look at the error as it appears.

Full configuration

If you want full control of the package behaviour publish the configuration file:

php artisan vendor:publish --provider="Inspector\InspectorServiceProvider"

That will add config/inspector.php in your Laravel configuration directory.

You can set the environment variables below:


Add Custom Segments

You can add custom segments in your timeline to measure the impact that a hidden code block has on a transaction performance.

Suppose you have a queued job that executes some database checks and an http request to an external service in background.

Job and queries are reported automatically, but it could be interesting to monitor and measure the execution of the http request. Simply use the Inspectorfacade:

use Inspector\Laravel\Facades\Inspector;

class TagUserAsActive extends Job
    protected $user;

    protected $guzzle;

     * Monitoring & Measure an external http request
    public function handle()
        try {
            // Add http call to your timeline
            $segment = Inspector::startSegment('http');
            $this->guzzle->post('[mail-marketing-url]/add_tag', [
                'email' => $htis->user->email,
                'tag' => 'active',

        } catch (GuzzleException $exception) {
        } finally {
            // End segment

You will see the impact of the new segment in your timeline.

Filter out Web Requests and Commands

You can customize the list of excluded web requests. Check ignore_url field in your config/inspector.php file:

 | Web request url to ignore
 | Add at this list the url schemes that you don't want monitoring
 | in your Inspector dashboard. You can also use wildcard expression (*).
'ignore_url' => [

In the same way you can exclude from your dashboard some artisan commands customizing the ignore_commands field in config/inspector.php file:

 | Artisan command to ignore
 | Add at this list all command signature that you don't want monitoring
 | in your Inspector dashboard.
'ignore_commands' => [