# PHP & Laravel > https://docs.errora.org/en/platforms/php-laravel ## Laravel ```bash composer require sentry/sentry-laravel php artisan sentry:publish --dsn=https://@/ ``` `sentry:publish` writes `config/sentry.php` and appends the DSN to `.env`: ```dotenv SENTRY_LARAVEL_DSN=https://@/ SENTRY_TRACES_SAMPLE_RATE=0.2 SENTRY_PROFILES_SAMPLE_RATE=1.0 SENTRY_ENVIRONMENT=production SENTRY_RELEASE=myapp@1.4.2 ``` ### Report exceptions Laravel 11+ (`bootstrap/app.php`): ```php ->withExceptions(function (Illuminate\Foundation\Configuration\Exceptions $exceptions) { Sentry\Laravel\Integration::handles($exceptions); }) ``` Laravel 10 and earlier: call `Integration::captureUnhandledException($e)` from the `register()` method of `app/Exceptions/Handler.php`. ### Tracing `SENTRY_TRACES_SAMPLE_RATE` alone instruments requests, queries, queue jobs, cache calls, HTTP client calls and view rendering. Add the middleware for full request transactions: ```php // bootstrap/app.php ->withMiddleware(function (Middleware $middleware) { $middleware->append(\Sentry\Laravel\Tracing\Middleware::class); }) ``` ### Logs ```php // config/logging.php 'channels' => [ 'sentry' => [ 'driver' => 'sentry', 'level' => env('LOG_LEVEL', 'info'), 'bubble' => true, ], 'stack' => ['driver' => 'stack', 'channels' => ['single', 'sentry']], ], ``` Then `Log::warning('payment retried', ['order_id' => $order->id]);` shows up in [Logs](/en/products/logs), context intact. ### Scheduled commands (cron monitoring) ```php $schedule->command('invoices:generate') ->dailyAt('03:00') ->sentryMonitor('nightly-invoices'); ``` The check-ins land against the monitor slug — see [Cron monitoring](/en/products/crons). ### User context ```php \Sentry\configureScope(function (\Sentry\State\Scope $scope) { $scope->setUser(['id' => auth()->id(), 'username' => auth()->user()?->name]); }); ``` ## Plain PHP ```bash composer require sentry/sdk ``` ```php \Sentry\init([ 'dsn' => getenv('SENTRY_DSN'), 'environment' => 'production', 'release' => 'myapp@1.4.2', 'traces_sample_rate' => 0.2, 'send_default_pii' => false, ]); try { riskyThing(); } catch (\Throwable $e) { \Sentry\captureException($e); } ``` ## Symfony ```bash composer require sentry/sentry-symfony ``` ```yaml # config/packages/sentry.yaml sentry: dsn: '%env(SENTRY_DSN)%' options: traces_sample_rate: 0.2 environment: '%kernel.environment%' ``` ## Verify ```bash php artisan sentry:test ``` That command sends a test exception through the configured DSN and prints the result. Then check **Issues**.