Laravel

Laravel SDK

Tindra uses the official Sentry Laravel SDK. No Tindra-specific package required.

Installation

composer require sentry/sentry-laravel

Configuration

Add to .env:

SENTRY_LARAVEL_DSN=https://your-key@your-hostname.tindra.sh/1

# Optional: capture 10% of requests for performance monitoring
SENTRY_TRACES_SAMPLE_RATE=0.1

Publish the config file:

php artisan vendor:publish --provider="Sentry\Laravel\ServiceProvider"

Error capturing

Automatic

Laravel integrates automatically. Exceptions thrown during request handling are captured and sent to Tindra.

Manual

use Sentry\State\Scope;

\Sentry\withScope(function (Scope $scope) use ($orderId, $exception) {
    $scope->setExtra('order_id', $orderId);
    \Sentry\captureException($exception);
});

Setting user context

\Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($user) {
    $scope->setUser([
        'id' => $user->id,
        'email' => $user->email,
    ]);
});

Put this in a middleware that runs after authentication.

Performance monitoring

Automatic instrumentation

When traces_sample_rate is set, the SDK automatically captures:

  • HTTP request/response timing
  • Database queries (PDO)
  • Redis commands
  • Queue job execution
  • Cache operations

Custom spans

\Sentry\trace(function () use ($data) {
    return generateCsvExport($data);
}, 'export.csv', 'Generate monthly report');

Queue jobs

Jobs dispatched via Laravel's queue are automatically instrumented when traces_sample_rate > 0. Exceptions in jobs are captured automatically.

Logging integration

Capture log entries as breadcrumbs:

// config/logging.php
'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'sentry'],
    ],
    'sentry' => [
        'driver' => 'sentry',
        'level' => 'warning',
        'bubble' => true,
    ],
],

Ignoring exceptions

// config/sentry.php
'ignore_exceptions' => [
    \Illuminate\Auth\AuthenticationException::class,
    \Illuminate\Validation\ValidationException::class,
    \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
],

Testing

php artisan sentry:test

A test event should appear in your Tindra dashboard within a few seconds.