sentry/sentry-laravel
Official Sentry SDK for Laravel. Automatically captures unhandled exceptions, performance data, and context from your app, sending issues and traces to Sentry for faster debugging and monitoring. Supports modern Laravel versions with simple Composer install.
bootstrap/app.php via the Integration::handles() method, ensuring minimal disruption to existing architecture.log_flush_threshold, trace sampling middleware) and includes instrumentation for critical Laravel components (e.g., cache, queues, HTTP requests).composer require and a one-line bootstrap/app.php modification. Configuration is environment-driven (.env + config/sentry.php).Illuminate\Queue\Events\JobProcessed) and supports custom integrations (e.g., Pennant feature flags).php artisan sentry:publish) and integrates with Laravel’s testing helpers (e.g., captureException() in tests).sentry/sentry-php SDK (~50MB) may impact cold starts in serverless environments (mitigated by lazy-loading).sentry/sentry-php for cross-platform features (e.g., OTLP, structured events) while adding Laravel-specific integrations (e.g., Eloquent queries, Blade templates).sentry-trace headers).SENTRY_ENABLE_LOGS=false to avoid noise.Integration::handles() in bootstrap/app.php)./checkout) using Sentry\startTransaction().trace_metrics()->count('orders_processed')).LOG_STACK=sentry_logs.Sentry\setTraceSampleRate(0.1)) for high-volume endpoints.2.14.x) and follow deprecated guides.laravel/framework version constraints in composer.json to avoid conflicts.json, curl, and openssl. No other extensions needed.whoops). Use Sentry\init() early in bootstrap/app.php.php artisan sentry:publish).Integration::handles() to bootstrap/app.php.use Sentry\Laravel\Integration;
public function handle(Request $request, Closure $next) {
Integration::startTransaction($request);
return $next($request);
}
LOG_STACK and SENTRY_ENABLE_LOGS.trace_metrics()->gauge('db_query_time')).QueryException)..env and config/sentry.php. Use tools like Laravel Envoy or Ansible to sync across environments.sentry/sentry-php releases for breaking changes. Pin major versions in composer.json:
"sentry/sentry-laravel": "^4.25",
"sentry/sentry": "^4.23"
storage/logs/sentry.log or disabling the SDK temporarily (SENTRY_LARAVEL_DSN=).Sentry\configureScope() to add context to events during debugging.SENTRY_DEBUG environment variable for SDK logs.error severity only.Sentry\setTraceSampleRate() to limit trace volume (e.g., 10% for staging).sentry.log_flush_threshold to reduce I/O (e.g., 100).SentryTracesSampleRate middleware to sample job traces.beforeSend callback:
Sentry\configureScope(function ($scope) {
$scope->setTag('env', app()->environment());
});
ignoreErrors to exclude known non-critical errors (e.g., deprecation notices).storage/logs/sentry.log has sufficient disk space.Sentry\init() in each worker.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Sentry API downtime | Events lost; no error visibility | Buffer events locally; set up fallback logging. |
| DSN misconfiguration | No events sent; silent failures | Validate DSN in CI/CD; use SENTRY_DEBUG=true. |
| Over-sampling traces | High costs; noisy dashboard | Set Sentry\setTraceSampleRate(0.1) by default. |
| PII in error reports | Compliance violations | Use beforeSend to redact data. |
| SDK version conflicts | Runtime errors | Pin versions in composer.json. |
| Laravel cache clearing | Lost transaction context | Use ` |
How can I help you explore Laravel packages today?