---
title: "Laravel Lumen"
description: "Learn about using Sentry with Laravel Lumen."
url: https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen/
---

# Laravel Lumen | Sentry for Laravel

Laravel is supported using a native package: [sentry-laravel](https://github.com/getsentry/sentry-laravel).

This guide is for Laravel Lumen 5+. We also provide instructions for [the latest Laravel](https://docs.sentry.io/platforms/php/guides/laravel.md) as well as [other versions](https://docs.sentry.io/platforms/php/guides/laravel/other-versions.md).

## [Install](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md#install)

Install the `sentry/sentry-laravel` package:

```bash
composer require sentry/sentry-laravel
```

Register Sentry in `bootstrap/app.php`:

`bootstrap/app.php`

```php
$app->register('Sentry\Laravel\ServiceProvider');

// To enable Sentry Tracing, the `TracingServiceProvider` has to be registered additionally:
// $app->register('Sentry\Laravel\Tracing\ServiceProvider');

// Sentry must be registered before routes are included
require __DIR__ . '/../app/Http/routes.php';
```

Add Sentry reporting to `app/Exceptions/Handler.php`:

`app/Exceptions/Handler.php`

```php
public function report(Throwable $exception)
{
    if (app()->bound('sentry') && $this->shouldReport($exception)) {
        app('sentry')->captureException($exception);
    }

    parent::report($exception);
}
```

## [Configure](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md#configure)

Copy the Sentry configuration file from the vendor directory:

```bash
cp vendor/sentry/sentry-laravel/config/sentry.php config/sentry.php
```

Afterwards, add your DSN to `.env`:

`.env`

```shell
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
```

## [Verify](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md#verify)

### [Verify With Artisan](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md#verify-with-artisan)

You can test your configuration using the provided `sentry:test` artisan command:

```shell
php artisan sentry:test
```

### [Verify With Code](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md#verify-with-code)

You can verify that Sentry is capturing errors in your Laravel application by creating a route that will throw an exception:

`routes/web.php`

```php
Route::get('/debug-sentry', function () {
    throw new Exception('My first Sentry error!');
});
```

Visiting this route will trigger an exception that will be captured by Sentry.

## [Local Development and Testing](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md#local-development-and-testing)

When Sentry is installed in your application, it will also be active when you are developing or running tests.

You most likely don't want errors to be sent to Sentry when you are developing or running tests. To avoid this, set the DSN value to `null` to disable sending errors to Sentry.

You can also do this by not defining `SENTRY_LARAVEL_DSN` in your `.env` or by defining it as `SENTRY_LARAVEL_DSN=null`.

If you do leave Sentry enabled when developing or running tests, it's possible for it to have a negative effect on the performance of your application or test suite.
