Laravel is supported via a native package, sentry-laravel.

This guide is for Laravel 8+. We also provide instructions for other versions as well as Lumen-specific instructions.


Install the sentry/sentry-laravel package:

composer require sentry/sentry-laravel

Add Sentry reporting to App/Exceptions/Handler.php.

public function register()
    $this->reportable(function (Throwable $e) {
        if ($this->shouldReport($e) && app()->bound('sentry')) {


Setup Sentry with this command:

php artisan sentry:publish --dsn=

It creates (config/sentry.php) and adds the DSN to your .env file.


Verify with Artisan

You can test your configuration using the provided artisan command:

php artisan sentry:test --transaction
[Sentry] DSN discovered!
[Sentry] Generating test Event
[Sentry] Sending test Event
[Sentry] Transaction sent: b22f130764c940c69d6860c212849d48
[Sentry] Event sent with ID: 4cde238791a9433c8876f4a545d9a95b

Verify with code

You can easily verify that Sentry is capturing errors in your Laravel application by creating a debug 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, set the DSN value to null to disable sending errors to Sentry.

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

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

Performance Monitoring

Set traces_sample_rate to a value greater than 0.0 after that, Performance Monitoring will be enabled.

'traces_sample_rate' => 1.0 # be sure to lower this in production to prevent quota issues

Performance data is transmitted using a new event type called "transactions", which you can learn about in Distributed Tracing. To capture transactions, you must install and configure your SDK to set the traces_sample_rate option to a nonzero value. The example configuration above will transmit 100% of captured traces. Be sure to lower this value in production otherwise you could burn through your quota quickly.

Learn more about sampling in Using Your SDK to Filter Events.

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").