---
title: "Laravel 6.x, and 7.x"
description: "Learn about using Sentry with Laravel 6.x, and 7.x."
url: https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel6-7/
---

# Laravel 6.x, and 7.x | Sentry for Laravel

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

This guide is for Laravel 6.x, and 7.x. We also provide instructions for [the latest Laravel](https://docs.sentry.io/platforms/php/guides/laravel.md) as well as [Lumen-specific instructions](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen.md).

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

Install the `sentry/sentry-laravel` package:

If you're on Laravel 5.5 or higher, the package will be auto-discovered. Otherwise you will need to manually configure it in your `config/app.php`.

`config/app.php`

```php
'providers' => array(
    // ...
    Sentry\Laravel\ServiceProvider::class,
),
'aliases' => array(
    // ...
    'Sentry' => Sentry\Laravel\Facade::class,
),
```

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

`App/Exceptions/Handler.php`

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

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

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

Configure the Sentry DSN with this command:

```shell
php artisan sentry:publish --dsn=___PUBLIC_DSN___
```

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

`.env`

```shell
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
```

In order to receive stack trace arguments in your errors, make sure to set `zend.exception_ignore_args: Off` in your php.ini

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

### [Verify With Artisan](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel6-7.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/laravel6-7.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/laravel6-7.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.
