Share on Twitter
Share on Facebook
Share on HackerNews
Share on LinkedIn

Logging Laravel Errors with Sentry

Today we’re announcing native integration with Laravel through our new sentry-laravel package. This is a drastic improvement over our previous support for Laravel error monitoring (via Monolog) as it ensures proper stack traces, minimal configuration, and expanded error monitoring features (such as application detection).

Getting Started with Laravel

We’ve made it even easier to get started debugging Laravel on Sentry.

Install the sentry/sentry-laravel package:

$ composer require sentry/sentry-laravel

Add the Sentry service provider and facade in config/app.php:

'providers' => array(
    // ...
    Sentry\SentryLaravel\SentryLaravelServiceProvider::class,
)

'aliases' => array(
    // ...
    'Sentry' => Sentry\SentryLaravel\SentryFacade::class,
)

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

public function report(Exception $e)
{
    app('sentry')->captureException($e);
    parent::report($e);
}

Create the Sentry configuration file (config/sentry.php):

$ php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"

From here, just toss the SENTRY_DSN in your .env file, or configure things via the config/sentry.php configuration.

Learn More

Take a look at the sentry-laravel project on GitHub to learn more about how things are implemented, as well as additional details on using it with Sentry.

Your code is broken. Let's Fix it.
Get Started

More from the Sentry blog

ChangelogCodecovDashboardsDiscoverDogfooding ChroniclesEcosystemError MonitoringEventsGuest PostsMobileOpen SourcePerformance MonitoringRelease HealthResourceSDK UpdatesSentry
© 2024 • Sentry is a registered Trademark
of Functional Software, Inc.