Top Related Projects
An elegant debug assistant for the Laravel framework.
A beautiful error page for Laravel apps
Debugbar for Laravel (Integrates PHP Debug Bar)
:dromedary_camel: Laravel log viewer
Bring Symfony's Var-Dump Server to Laravel
Quick Overview
Sentry-Laravel is an official Laravel integration for Sentry, a popular error tracking and performance monitoring platform. It allows developers to easily integrate Sentry's error reporting and performance monitoring capabilities into their Laravel applications, providing real-time insights into application errors and performance issues.
Pros
- Easy integration with Laravel applications
- Automatic capture of errors and exceptions
- Performance monitoring and distributed tracing support
- Customizable error reporting and filtering options
Cons
- Requires a Sentry account and DSN for setup
- May add a slight performance overhead to the application
- Limited free tier for Sentry's hosted service
- Learning curve for advanced configuration and usage
Code Examples
- Basic error reporting:
try {
$this->someMethodThatMightFail();
} catch (\Exception $e) {
\Sentry\captureException($e);
}
- Adding custom context to events:
\Sentry\configureScope(function (\Sentry\State\Scope $scope): void {
$scope->setUser(['id' => Auth::id()]);
$scope->setTag('app.version', '1.0.3');
});
- Performance monitoring:
\Sentry\startTransaction(
'process-order',
['op' => 'transaction']
);
// ... your code ...
\Sentry\getCurrentTransaction()->finish();
Getting Started
-
Install the package via Composer:
composer require sentry/sentry-laravel
-
Add the Sentry DSN to your
.env
file:SENTRY_LARAVEL_DSN=your-sentry-dsn
-
Add the Sentry service provider in
config/app.php
:'providers' => [ // ... Sentry\Laravel\ServiceProvider::class, ],
-
(Optional) Publish the configuration file:
php artisan vendor:publish --provider="Sentry\Laravel\ServiceProvider"
-
Start reporting errors and monitoring performance in your Laravel application!
Competitor Comparisons
An elegant debug assistant for the Laravel framework.
Pros of Telescope
- Built-in Laravel integration, offering seamless compatibility and native feel
- Provides a comprehensive dashboard for monitoring various aspects of Laravel applications
- Free and open-source, with active community support
Cons of Telescope
- Limited to Laravel applications, lacking cross-platform support
- May require more manual configuration for advanced monitoring scenarios
- Potential performance impact on production environments if not properly configured
Code Comparison
Telescope (Laravel service provider registration):
protected function register(): void
{
$this->app->singleton(
IncomingEntry::class,
IncomingEntryRepository::class
);
}
Sentry Laravel (Error reporting setup):
\Sentry\init(['dsn' => 'https://examplePublicKey@o0.ingest.sentry.io/0']);
$this->app->singleton(Sentry::class, function () {
return new Sentry();
});
Telescope focuses on providing a native Laravel monitoring solution with a comprehensive dashboard, while Sentry Laravel offers cross-platform error tracking and performance monitoring. Telescope is ideal for Laravel-specific projects, whereas Sentry Laravel provides broader application support and advanced error tracking features. The choice between the two depends on project requirements, existing infrastructure, and the need for cross-platform compatibility.
A beautiful error page for Laravel apps
Pros of Ignition
- Built specifically for Laravel, offering deep integration and Laravel-specific features
- Provides a more user-friendly and interactive error page with detailed stack traces
- Includes solution suggestions for common errors, helping developers quickly resolve issues
Cons of Ignition
- Limited to Laravel applications, unlike Sentry which supports multiple platforms
- Lacks advanced features like performance monitoring and release tracking
- Does not offer a centralized error monitoring dashboard for multiple projects
Code Comparison
Ignition setup:
use Facade\Ignition\Exceptions\ViewException;
class Handler extends ExceptionHandler
{
protected $dontReport = [
ViewException::class,
];
}
Sentry setup:
use Sentry\Laravel\Integration;
$app->register(Integration::class);
$app->make('sentry')->init(['dsn' => 'your-sentry-dsn']);
Both packages offer easy integration with Laravel applications, but their setup processes differ. Ignition is typically pre-configured in Laravel projects, while Sentry requires explicit initialization with a DSN.
Ignition focuses on providing an enhanced local development experience with its interactive error pages, while Sentry offers a more comprehensive error tracking and monitoring solution across multiple environments and platforms.
Debugbar for Laravel (Integrates PHP Debug Bar)
Pros of Laravel Debugbar
- Provides real-time debugging information directly in the browser
- Offers detailed query analysis and performance metrics
- Integrates seamlessly with Laravel's built-in features
Cons of Laravel Debugbar
- Limited to local development environment; not suitable for production monitoring
- Requires manual setup and configuration for each project
- May impact application performance when enabled
Code Comparison
Laravel Debugbar:
use Barryvdh\Debugbar\Facade as Debugbar;
Debugbar::info('Info message');
Debugbar::error('Error message');
Debugbar::warning('Warning message');
Sentry Laravel:
use Sentry\Laravel\Facade as Sentry;
Sentry::captureMessage('Info message');
Sentry::captureException($exception);
Sentry::captureEvent($event);
Summary
Laravel Debugbar is an excellent tool for local development, providing real-time insights and performance metrics directly in the browser. It's particularly useful for query analysis and debugging during development.
Sentry Laravel, on the other hand, is designed for production-level error tracking and monitoring. It offers robust error reporting, performance monitoring, and release tracking across multiple environments.
While Laravel Debugbar excels in local debugging, Sentry Laravel provides a more comprehensive solution for production monitoring and error tracking across different environments and platforms.
:dromedary_camel: Laravel log viewer
Pros of Laravel Log Viewer
- Simple and lightweight solution for viewing Laravel logs
- Easy to set up and use without extensive configuration
- Provides a web-based interface for browsing log files
Cons of Laravel Log Viewer
- Limited to viewing local log files only
- Lacks advanced features like error tracking and performance monitoring
- No real-time log streaming or alerting capabilities
Code Comparison
Laravel Log Viewer:
Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');
Sentry Laravel:
use Sentry\Laravel\Facade as Sentry;
Sentry::captureException($exception);
Laravel Log Viewer provides a simple route for accessing logs, while Sentry Laravel offers more comprehensive error capturing and reporting functionality.
Summary
Laravel Log Viewer is a lightweight solution for viewing local log files, ideal for simple projects or development environments. It's easy to set up but lacks advanced features.
Sentry Laravel, on the other hand, offers a more robust error tracking and monitoring solution with features like real-time alerts, performance monitoring, and distributed tracing. It's better suited for production environments and larger applications that require comprehensive error management.
Choose Laravel Log Viewer for quick, local log viewing, or opt for Sentry Laravel when you need advanced error tracking and monitoring capabilities in a production environment.
Bring Symfony's Var-Dump Server to Laravel
Pros of laravel-dump-server
- Lightweight and focused solely on debugging
- Provides a dedicated dump server for viewing debug output
- Easy to set up and use within Laravel projects
Cons of laravel-dump-server
- Limited to local development environments
- Lacks advanced error tracking and monitoring features
- No built-in alerting or notification system
Code Comparison
laravel-dump-server:
use BeyondCode\DumpServer\Dumper;
$dumper = new Dumper($connection);
$dumper->dump($variable);
sentry-laravel:
use Sentry\Laravel\Facade as Sentry;
Sentry::captureException($exception);
Sentry::captureMessage('Custom message');
Summary
Laravel Dump Server is a lightweight debugging tool for local development, offering a dedicated server for viewing dump output. Sentry Laravel, on the other hand, is a comprehensive error tracking and monitoring solution suitable for both development and production environments. While Laravel Dump Server excels in simplicity and ease of use for debugging, Sentry Laravel provides more advanced features like error tracking, performance monitoring, and alerting capabilities.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions
Official Sentry SDK for Laravel
This is the official Laravel SDK for Sentry.
Getting Started
The installation steps below work on version 11.x of the Laravel framework.
For older Laravel versions and Lumen see:
Install
Install the sentry/sentry-laravel
package:
composer require sentry/sentry-laravel
Enable capturing unhandled exception to report to Sentry by making the following change to your bootstrap/app.php
:
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Sentry\Laravel\Integration;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
Integration::handles($exceptions);
})->create();
Alternatively, you can configure Sentry as a Laravel Log Channel, allowing you to capture
info
anddebug
logs as well.
Configure
Configure the Sentry DSN with this command:
php artisan sentry:publish --dsn=___PUBLIC_DSN___
It creates the config file (config/sentry.php
) and adds the DSN
to your .env
file.
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
Usage
use function Sentry\captureException;
try {
$this->functionThatMayFail();
} catch (\Throwable $exception) {
captureException($exception);
}
To learn more about how to use the SDK refer to our docs.
Laravel Version Compatibility
The Laravel and Lumen versions listed below are all currently supported:
- Laravel
>= 11.x.x
on PHP>= 8.2
is supported starting from4.3.0
- Laravel
>= 10.x.x
on PHP>= 8.1
is supported starting from3.2.0
- Laravel
>= 9.x.x
on PHP>= 8.0
is supported starting from2.11.0
- Laravel
>= 8.x.x
on PHP>= 7.3
is supported starting from1.9.0
- Laravel
>= 7.x.x
on PHP>= 7.2
is supported starting from1.7.0
- Laravel
>= 6.x.x
on PHP>= 7.2
is supported starting from1.2.0
Please note that starting with version >= 2.0.0
we require PHP Version >= 7.2
because we are using our new PHP SDK underneath.
The Laravel versions listed below were supported in previous versions of the Sentry SDK for Laravel:
- Laravel
<= 4.2.x
is supported until0.8.x
- Laravel
<= 5.7.x
on PHP<= 7.0
is supported until0.11.x
- Laravel
>= 5.x.x
on PHP>= 7.1
is supported until2.14.x
Contributing to the SDK
Please refer to CONTRIBUTING.md.
Getting Help/Support
If you need help setting up or configuring the Laravel SDK (or anything else in the Sentry universe) please head over to the Sentry Community on Discord. There is a ton of great people in our Discord community ready to help you!
Resources
License
Licensed under the MIT license, see LICENSE
.
Top Related Projects
An elegant debug assistant for the Laravel framework.
A beautiful error page for Laravel apps
Debugbar for Laravel (Integrates PHP Debug Bar)
:dromedary_camel: Laravel log viewer
Bring Symfony's Var-Dump Server to Laravel
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot