Introduction #
Laravel Pulse is Laravel's first‑party monitoring solution that provides real‑time insights into your application's performance, queues, cache, database queries, and more. It ships with a beautiful dashboard powered by Tailwind CSS and Livewire, making it easy to spot bottlenecks without leaving your development environment.
Prerequisites #
- Laravel 10 or higher
- PHP 8.1+
- A database connection (MySQL, PostgreSQL, SQLite, etc.)
1. Installation #
Run the Composer command to pull the package into your project:
composer require laravel/pulse
After installing, publish the assets and run the migration that creates the pulse_entries table:
php artisan pulse:install
php artisan migrate
The installation command also registers the Pulse service provider and publishes the dashboard view.
2. Configuration #
Pulse works out‑of‑the‑box, but you can fine‑tune what gets recorded in the config/pulse.php file.
<?php
return [
// The number of days to retain Pulse entries.
'recorders' => [
\Laravel\Pulse\Recorders\QueueRecorder::class => [
'max_attempts' => 3,
],
\Laravel\Pulse\Recorders\CacheRecorder::class,
\Laravel\Pulse\Recorders\DbQueryRecorder::class,
// Add or remove recorders as needed.
],
'storage' => [
'driver' => env('PULSE_STORAGE_DRIVER', 'database'),
],
];
You may also set the PULSE_STORAGE_DRIVER environment variable to redis if you prefer Redis storage.
3. Accessing the Dashboard #
Pulse registers a route at /pulse. By default, it is protected by the web middleware group and Laravel's authentication guard.
// routes/web.php
Route::middleware(['web', 'auth'])->group(function () {
Route::get('/pulse', \Laravel\Pulse\Http\Controllers\DashboardController::class)
->name('pulse.dashboard');
});
Visit http://your-app.test/pulse after logging in to see charts for:
- Queue job latency & failures
- Cache hits & misses
- HTTP request timing
- Database query performance
- Exceptions and more
4. Custom Recorders #
If you need to monitor something specific, create a custom recorder:
php artisan make:recorder CustomMetricRecorder
<?php
namespace App\Recorders;
use Laravel\Pulse\Recorders\Recorder;
class CustomMetricRecorder extends Recorder
{
public function record(): void
{
// Example: Record the number of active users every minute
$active = \App\Models\User::where('last_activity', '>=', now()->subMinutes(5))->count();
$this->store('custom_metrics', ['active_users' => $active]);
}
}
Add the new recorder to config/pulse.php and it will start appearing on the dashboard.
5. Production Considerations #
- Retention: Adjust
pulse.retentionto control how long data is kept. - Performance: Recorders run on a schedule (default every minute). They are lightweight, but avoid heavy queries inside
record(). - Security: Keep the dashboard behind authentication and consider IP restrictions.
Conclusion #
Laravel Pulse gives you instant visibility into the health of your Laravel application with virtually no setup cost. By installing, configuring, and optionally extending it with custom recorders, you can proactively detect performance issues and keep your app running smoothly.
Quick Reference #
| Step | Command |
|---|---|
| Install | composer require laravel/pulse |
| Publish & Migrate | php artisan pulse:install && php artisan migrate |
| View Dashboard | Visit /pulse (authenticated) |
| Add Custom Recorder | php artisan make:recorder MyRecorder |
Happy monitoring!