Laravel 5.x and 6.x
Install
Install the sentry/sentry-laravel
package:
Copied
composer require sentry/sentry-laravel
Add Sentry reporting to App/Exceptions/Handler.php
.
App/Exceptions/Handler.php
Copied
public function report(Exception $exception)
{
if ($this->shouldReport($exception) && app()->bound('sentry')) {
app('sentry')->captureException($exception);
}
parent::report($exception);
}
If you're on Laravel 5.5 or later the package will be auto-discovered. Otherwise you will need to manually configure it in your config/app.php
.
config/app.php
Copied
'providers' => array(
// ...
Sentry\Laravel\ServiceProvider::class,
),
'aliases' => array(
// ...
'Sentry' => Sentry\Laravel\Facade::class,
),
Configure
Run:
Copied
php artisan sentry:publish
that creates the Sentry configuration file (config/sentry.php
).
Afterwards, add your DSN to .env
:
.env
Copied
SENTRY_LARAVEL_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
Verify Setup
You can easily verify that Sentry is capturing errors in your Laravel application by creating a debug route that will throw an exception:
Copied
Route::get('/debug-sentry', function () {
throw new Exception('My first Sentry error!');
});
You can edit this page on GitHub.
- Package:
- composer:sentry/sentry-laravel
- Version:
- 2.3.1
- Repository:
- https://github.com/getsentry/sentry-laravel