Laravel Lumen

Laravel is supported using a native package: sentry-laravel.

This guide is for Laravel Lumen 5+. We also provide instructions for the latest Laravel as well as other versions.


Install the sentry/sentry-laravel package:

composer require sentry/sentry-laravel

Register Sentry in bootstrap/app.php:


// To enable Sentry Performance Monitoring, 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:

public function report(Throwable $exception)
    if (app()->bound('sentry') && $this->shouldReport($exception)) {



Copy the Sentry configuration file from the vendor directory:

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

Afterwards, add your

DSNThe Data Source Name (DSN) key tells the Sentry SDK where to send events, ensuring they go to the right project.
to .env:



Verify With Artisan

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

php artisan sentry:test

Verify With Code

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

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

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

DSNThe Data Source Name (DSN) key tells the Sentry SDK where to send events, ensuring they go to the right project.
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.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
Suggest an edit to this page   |  Contribute to Docs   |  

Report a Problem

🎉 Thank you for your feedback! 🙌
Report a problem