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.
Pros:
bootstrap/app.php hooks, service providers, and event listeners).captureException(), and log channels.trace_metrics().OTLPIntegration for OpenTelemetry) and middleware for fine-grained control (e.g., SentryTracesSampleRate for job sampling).Cons:
Integration::handles($exceptions) hook in bootstrap/app.php is a minimal but powerful integration point.SentryTracesSampleRate).sentry_logs).whoops, laravel-debugbar) or monitoring tools (e.g., New Relic, Datadog). Requires careful configuration to avoid duplicate events.traceparent headers and baggage propagation. Misconfiguration can lead to broken traces or excessive noise.SENTRY_ENABLE_LOGS=true) simplifies setup but may introduce unexpected behavior if not tested thoroughly.SENTRY_LOGS_LEVEL → SENTRY_LOG_LEVEL) are backward-compatible but should be audited during upgrades.trace_sample_rate) be adjusted?Integration::handles($exceptions).Sentry\Laravel\ServiceProvider).Sentry\Laravel\Integration\LivewireIntegration.SentryTracesSampleRate middleware to control trace sampling.sentry_logs as a log channel (requires LOG_CHANNEL=stack and LOG_STACK=single,sentry_logs).OTLPIntegration for cross-tool compatibility.Sentry\Laravel\Integration\DatabaseIntegration.Sentry\Laravel\Integration\HttpIntegration for outbound request tracing.whoops, custom handlers) and define scope (e.g., "capture all 5xx errors and critical exceptions").composer require sentry/sentry-laravel
php artisan sentry:publish --dsn=YOUR_DSN
bootstrap/app.php:
Integration::handles($exceptions);
try { /* risky code */ } catch (\Throwable $e) { \Sentry\captureException($e); }
Sentry\Laravel\Integration\HttpIntegration).DatabaseIntegration).SENTRY_ENABLE_LOGS=false).trace_sample_rate=0.1 for 10% sampling).^4.26.0 for Laravel 11/12).json, openssl, and pcntl (for CLI). No additional extensions needed for core functionality.SENTRY_LARAVEL_DSN: Mandatory for event ingestion.How can I help you explore Laravel packages today?