sentry/sentry-laravel
Official Sentry SDK for Laravel. Automatically capture and report unhandled exceptions and performance data to Sentry, with seamless Laravel integration and configuration. Supports modern Laravel versions and includes tooling for monitoring errors in production.
Observability & Debugging Roadmap:
Developer Experience (DX) Improvements:
Compliance & Auditing:
Cost Optimization:
| Use Case | Alternative Tools |
|---|---|
| Lightweight error tracking | Laravel’s built-in logging + monolog |
| Open-source APM | OpenTelemetry + Jaeger/Grafana |
| Self-hosted observability | Self-hosted Sentry or OpenSearch + Filebeat |
| Budget constraints | Roll your own (e.g., Logstash + Elasticsearch) |
"Sentry for Laravel is a strategic investment to reduce downtime and accelerate debugging in production. By integrating this package, we’ll:*
- Cut MTTR by 50%: Automatically capture errors, logs, and performance issues with rich context (e.g., user sessions, request data), so engineers spend less time guessing and more time fixing.
- Scale reliably: Sentry handles millions of events/day for enterprises like Discord and Shopify—we leverage their infrastructure without over-engineering.
- Future-proof observability: Supports traces, metrics, and structured logs, enabling us to monitor performance as we scale (e.g., for [Roadmap Item X]).
- Lower costs: Avoids hiring dedicated SREs to build/maintain custom monitoring; Sentry’s pricing scales with our needs (free tier covers early-stage).
Ask: ‘What’s the cost of one hour of downtime for our users? Sentry pays for itself by preventing that.’"*
"This is a drop-in solution for Laravel’s observability gaps. Here’s why it’s a no-brainer:
- Zero architecture changes: Integrates via
composer requireand a few config lines. Works with Laravel 11/12/Lumen.- Automates 80% of debugging: Catches exceptions, logs, and traces without manual instrumentation. Example: A failed payment job now auto-sends the queue payload, user ID, and database query to Sentry.
- Unifies tooling: Replaces fragmented logging (e.g.,
log::error()+syslog) with a single source of truth for errors, performance, and logs.- Extensible: Add custom context (e.g.,
Sentry\configureScope(fn($scope) => $scope->setTag('feature_flag', $user->hasFlag('beta')))).- Performance insights: Track slow endpoints, database queries, and external API calls via distributed tracing.
Trade-offs:
- Sentry is cloud-first (self-hosting adds ops overhead).
- Free tier has event volume limits (plan for $29/month at scale).
Next steps: I’ll demo the setup in 15 mins—we can have this running in <1 hour."*
"Sentry for Laravel makes debugging effortless. Here’s how it works:
- Install:
composer require sentry/sentry-laravel+ configure.env.- Autocapture: All unhandled exceptions are sent to Sentry automatically (no try/catch boilerplate).
- Rich context: Errors include:
- User ID (if authenticated).
- Request data (headers, payload).
- Environment variables (e.g.,
APP_DEBUG).- Traces: Measure endpoint performance with
@sentry.tracing:\Sentry\startSpan('process_order')->__enter(); // ... code ...- Logs: Send structured logs to Sentry:
Log::channel('sentry_logs')->info('Failed login', ['user_id' => $user->id]);Why this beats manual logging:
- No more digging through
storage/logs: Errors are searchable in Sentry’s UI with filters (e.g.,user_id:123).- Collaborative debugging: Share error links with QA/designers (e.g., ‘Check this crash in Sentry’).
- Proactive alerts: Set up rules to notify Slack for
Database\QueryException.Gotchas:
- DSN security: Never commit
.envto Git (useSENTRY_LARAVEL_DSN).- Sampling: Disable in dev (
SENTRY_TRACES_SAMPLE_RATE=0).Let’s try it on [Project Y]—I’ll show you how to add it to a single route in 5 mins."
"Sentry helps us audit and secure the application by:
- Tracking sensitive operations: Log failed payment attempts, admin actions, or data exports with structured events.
- Compliance-ready: Retain logs/traces for SOC2/GDPR (Sentry offers data residency options).
- Anomaly detection: Alert on unusual
How can I help you explore Laravel packages today?