rcrowe/laravel-sentry
Laravel integration for Sentry error tracking. Reports exceptions and log events to Sentry so production errors arrive with stack traces and context, configured through a simple package config. An older package, so verify compatibility with current Laravel and Sentry SDK versions.
This package wires the Sentry PHP SDK into Laravel so exceptions and log entries are reported to a Sentry project without hand-writing a client. It predates (and is superseded by) sentry/sentry-laravel, so treat it as a legacy integration you inherit rather than one you reach for greenfield.
Minimal setup:
composer require rcrowe/laravel-sentry. Because the package is old (Laravel 4/5 era, illuminate/support ~4.x–5.x), check the resolved constraint against your framework version before anything else. On modern Laravel this will not install cleanly — that alone is usually the deciding factor.app/config/app.php (providers array) or let package discovery handle it on the Laravel 5 versions it supports: Rcrowe\Sentry\SentryServiceProvider.'Sentry' => Rcrowe\Sentry\Facades\Sentry::class) if the package’s facade is not auto-aliased.php artisan config:publish rcrowe/laravel-sentry on L4, vendor:publish on L5) and set the DSN, typically from .env:// app/config/packages/rcrowe/laravel-sentry/config.php (L4)
// or config/sentry.php (L5)
return [
'dsn' => getenv('SENTRY_DSN'),
'level' => 'error', // minimum log level forwarded
];
Where to look first: the config file (what actually gets sent), then the service provider (what it binds into the container and which Laravel error/log hooks it registers), then the facade (the public surface you'll call).
First use case: prove the pipe works. Trigger a deliberate exception in a staging environment and confirm it lands in Sentry with a readable stack trace and the right environment/release tags. Do this before wiring anything into App::error or the log stack — otherwise you cannot tell a broken DSN from a broken handler.
Catch-and-report at boundaries. The most reliable pattern with this package is explicit capture at application boundaries (controllers, queued jobs, console commands) rather than relying solely on global hooks:
try {
$this->chargeCard($order);
} catch (\Exception $e) {
Sentry::captureException($e);
throw $e; // keep Laravel's normal handling intact
}
This keeps reporting intentional and avoids sending every NotFoundHttpException and validation failure to Sentry.
Wire the global error handler once. For uncaught exceptions, hook Laravel's error handler instead of repeating try/catch everywhere:
// L4: app/start/global.php or a service provider boot()
App::error(function (\Exception $e, $code) {
if (App::environment('production')) {
Sentry::captureException($e);
}
});
Guard by environment — reporting every exception from local dev is the fastest way to make Sentry useless.
Use the log handler for breadcrumbs, not spam. This package’s differentiator is routing Log::error()/Log::critical() calls into Sentry. Keep the threshold at error and let info/debug stay in your normal log channel. This gives you a single Log::error($message, ['context' => ...]) call that both writes locally and alerts remotely.
Attach context deliberately. Pass user id, route, tenant, and any correlation id you already have. Sentry without user/tenant context produces alerts you can’t triage:
Sentry::captureException($e, [
'user' => ['id' => Auth::id()],
'extra' => ['order_id' => $order->id, 'tenant' => $tenant->slug],
]);
Integrate at the framework seam, not in business logic. Wrap it in your own ErrorReporter interface bound in the container so application code depends on your abstraction, not on rcrowe/laravel-sentry. When you migrate to sentry/sentry-laravel (or drop Sentry), you swap one binding instead of grepping the codebase.
Queue-safe reporting. In queued jobs, report inside failed() or in the job’s catch block so the failure is associated with the job context; otherwise the report arrives detached from the retry/backoff that actually matters.
composer require resolves to something ancient or conflicts with your framework, stop — use sentry/sentry-laravel, which is actively maintained and supports modern Laravel, framework-agnostic contexts, and performance tracing.Rcrowe\Sentry\Facades\Sentry vs. an alias like Sentry) and config path against the version you installed; older docs and blog posts disagree..env and make sure the published config reads from it rather than hardcoding.App::error hook and the log handler fire for the same exception, you'll get doubles in Sentry. Pick one primary path (typically the error hook) and keep the log handler for Log::error() calls you make yourself.ValidationException) before capture. Left unguarded, this integration will happily report everything and mask real regressions.ErrorReporter in the container, or configure a null/no-op client in the testing environment so suite runs stay hermetic and fast.How can I help you explore Laravel packages today?