Guides

PHP

Use the official Sentry packages: sentry/sentry-laravel on Laravel, sentry/sentry-symfony on Symfony, and sentry/sentry for everything else.

Laravel

Install the package and publish its config with your DSN, which it adds to .env as SENTRY_LARAVEL_DSN:

Terminal
composer require sentry/sentry-laravel
php artisan sentry:publish --dsn=https://<key>@uncaught.thistinct.tools/<project-id>

Then report exceptions from bootstrap/app.php (Laravel 11 and later):

bootstrap/app.php
use Illuminate\Foundation\Configuration\Exceptions;
use Sentry\Laravel\Integration;

return Application::configure(basePath: dirname(__DIR__))
    ->withExceptions(function (Exceptions $exceptions) {
        Integration::handles($exceptions);
    })
    ->create();

Check it with php artisan sentry:test. Set SENTRY_TRACES_SAMPLE_RATE=0.1 in .env to time requests for Performance.

Symfony

Terminal
composer require sentry/sentry-symfony

Set SENTRY_DSN in .env, and the bundle reports errors from controllers and console commands.

Plain PHP

Terminal
composer require sentry/sentry

Initialize it once, at the start of every request or script:

PHP
<?php
require __DIR__ . '/vendor/autoload.php';

\Sentry\init([
    'dsn' => getenv('SENTRY_DSN'),
    'environment' => 'production',
    'release' => getenv('GIT_SHA'),
    'prefixes' => [__DIR__], // report paths relative to your app, so they link to GitHub
    'traces_sample_rate' => 0.1,
]);

try {
    syncInventory();
} catch (\Throwable $exception) {
    \Sentry\captureException($exception);
    throw $exception;
}

Uncaught errors are reported on their own once the SDK is initialized.

Add context

PHP
\Sentry\configureScope(function (\Sentry\State\Scope $scope): void {
    $scope->setUser(['id' => $user->id, 'email' => $user->email]);
    $scope->setTag('queue', 'imports');
});

Deploys

Issues stay grouped across deploys, even when each one lands in a new directory like releases/20261029120000/ with Envoyer, Deployer or Forge.