Laravel

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

Laravel 5.x

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)
{
    if ($this->shouldReport($e)) {
        app('sentry')->captureException($e);
    }
    parent::report($e);
}

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

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

Add your DSN to .env:

SENTRY_DSN=___DSN___

Finally, if you wish to wire up User Feedback, you can do so by creating a custom error response. To do this, open up App/Exceptions/Handler.php and except the render method:

<?php

class Handler extends ExceptionHandler
{
    private $sentryID;

    public function report(Exception $e)
    {
        if ($this->shouldReport($e)) {
            // bind the event ID for Feedback
            $this->sentryID = app('sentry')->captureException($e);
        }
        parent::report($e);
    }

    // ...
    public function render($request, Exception $e)
    {
        return response()->view('errors.500', [
            'sentryID' => $this->sentryID,
        ], 500);
    }
}

Next, create resources/views/errors/500.blade.php, and embed the feedback code:

<div class="content">
    <div class="title">Something went wrong.</div>
    @unless(empty($sentryID))
        <!-- Sentry JS SDK 2.1.+ required -->
        <script src="https://cdn.ravenjs.com/3.3.0/raven.min.js"></script>

        <script>
        Raven.showReportDialog({
            eventId: '{{ $sentryID }}',

            // use the public DSN (dont include your secret!)
            dsn: '___PUBLIC_DSN___'
        });
        </script>
    @endunless
</div>

That’s it!

Laravel 4.x

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',
)

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

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

$ php artisan config:publish sentry/sentry-laravel

Add your DSN to config/sentry.php:

<?php

return array(
    'dsn' => '___DSN___',

    // ...
);

If you wish to wire up Sentry anywhere outside of the standard error handlers, or if you need to configure additional settings, you can access the Sentry instance through $app:

$app['sentry']->setRelease(Git::sha());

Lumen 5.x

Install the sentry/sentry-laravel package:

$ composer require sentry/sentry-laravel

Register Sentry in bootstrap/app.php:

$app->register('Sentry\SentryLaravel\SentryLumenServiceProvider');

# 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(Exception $e)
{
    if ($this->shouldReport($e)) {
        app('sentry')->captureException($e);
    }
    parent::report($e);
}

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

<?php

return array(
    'dsn' => '___DSN___',

// capture release as git sha
// 'release' => trim(exec('git log --pretty="%h" -n1 HEAD')),
);

Available Settings

The following settings are available for the client:

dsn

The DSN to authenticate with Sentry.

'dsn' => '___DSN___',
release

The version of your application (e.g. git SHA)

'release' => MyApp::getReleaseVersion(),
breadcrumbs.sql_bindings

Capturing bindings on SQL queries.

Defaults to true.

'breadcrumbs.sql_bindings' => false,