Lumen

Lumen

Scout supports Lumen 5.5+.

Installing the package

1. Install the scoutapp/scout-apm-lumen package:

composer require scoutapp/scout-apm-lumen

Note that the scout-apm-php package will automatically be included. It does not need to be installed directly.

2. Adding the service provider:

Add the ScoutApmServiceProvider to your bootstrap/app.php, for example:

// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(\Scoutapm\Laravel\Providers\ScoutApmServiceProvider::class);

Add the four middleware to your bootstrap/app.php, for example:

$app->middleware([
    // These three should be as early as possible in the pipeline:
    \Scoutapm\Laravel\Middleware\SendRequestToScout::class,
    \Scoutapm\Laravel\Middleware\IgnoredEndpoints::class,
    \Scoutapm\Laravel\Middleware\MiddlewareInstrument::class,
    
    // The rest of your middleware should go here
    // ...
    
    // This middleware should come last
    \Scoutapm\Laravel\Middleware\ActionInstrument::class,
]);

If you wish to use the \Scoutapm\Laravel\Facades\ScoutApm facade, you should also enable facades if you did not already by uncommenting the withFacades() call in bootstrap/app.php:

$app->withFacades();

3. Install the scoutapm php extension (optional, recommended):

sudo pecl install scoutapm

Several instruments require the native extension to be included, including timing of libcurl and file_get_contents. For more information, or to compile manually, the README has additional instructions.

4. Configuring the agent

Configure Scout in your .env file:

# Scout settings
SCOUT_MONITOR=true
SCOUT_KEY="[AVAILABLE IN THE SCOUT UI]"
SCOUT_NAME="A FRIENDLY NAME FOR YOUR APP"

If you’ve installed Scout via the Heroku Addon, the provisioning process automatically sets SCOUT_MONITOR and SCOUT_KEY via config vars. Only SCOUT_NAME is required.

5. Deploy.

It takes approximatively five minutes for your data to first appear within the Scout UI.