Laravel
Package for Laravel 10+
What it is for
The official DockRay package integrates Laravel applications with the monitoring platform, enabling automatic exception reporting and HTTP request performance monitoring. Events are sent directly to the DockRay dashboard along with the information needed to quickly diagnose issues.
Error and Exception Monitoring
DockRay integrates with Laravel’s exception reporting system and automatically sends application errors to a single monitoring dashboard.
Reported events can include:
- the exception type and message,
- where the exception occurred and the stack trace,
- environment and application version information,
- context related to the request being processed.
Selected exception classes can be excluded from reporting. DockRay also respects Laravel’s standard dontReport configuration.
Performance Monitoring
The package can monitor HTTP request processing times for selected middleware groups, such as web and api. Transactions are grouped by route pattern, allowing requests to the same route to be analyzed together regardless of the IDs passed in the URL.
The frequency of transaction data collection can be controlled using a sampling rate.
User Context and Privacy
DockRay can optionally include information about the authenticated user with reported events, such as their ID, email address, and name. Sending the IP address and user agent is controlled by a separate setting and does not need to be enabled by default.
Queues and Artisan Commands
Errors occurring in queues and console processes can also be reported to DockRay. Because they run outside the HTTP middleware stack, they do not generate performance transactions.
Safe Reporting
DockRay’s reporting methods do not throw exceptions, so temporary monitoring platform outages do not interfere with your application’s standard error handling.
Installation
Package Installation
Install DockRay using Composer:
composer require dockcodes/dock-ray-laravel
Then publish the configuration file:
php artisan vendor:publish --tag=ray-config
The Service Provider is automatically discovered by Laravel and does not require manual registration.
Configuration
Add your DockRay project credentials to the .env file:
RAY_TOKEN=project-token
RAY_PRIVATE_KEY=project-private-key
RAY_TRACES_SAMPLE_RATE=0.2
You can find your project token and private key in the DockRay dashboard. If RAY_TOKEN and RAY_PRIVATE_KEY are not set, the package remains inactive and does not send any data.
All other integration settings are available in the config/ray.php file.
How to use it
The integration reports exceptions on its own. This is for the reports you send deliberately.
<?php
use Dock\Ray\Laravel\Ray;
use Illuminate\Foundation\Configuration\Exceptions;
->withExceptions(function (Exceptions $exceptions) {
$exceptions->reportable( fn (Throwable $exception) => Ray::report($exception) );
})
Knowledge base articles
Other integrations
All integrationsWordPress and WooCommerce Plugin
Explore integrationModule for PrestaShop 1.7.8+, 8.x, and 9.x
Explore integrationPlugin for Joomla 4, 5, and 6
Explore integrationModule for Drupal 10.2+ and 11
Explore integrationModule for Magento 2.4 and Adobe Commerce
Explore integrationBundle for Symfony 6.4+
Explore integrationLibrary for PHP Applications
Explore integrationClient for Django, FastAPI, Flask, and Scripts
Explore integrationStart Monitoring
Connect your first application and get full visibility into what’s happening in production.