spatie/laravel-health
Monitor your Laravel app’s health by registering checks (disk space, etc.) with warning/fail thresholds. Get notified via mail or Slack when checks degrade, and extend with custom checks for proactive alerting.
To improve performance, Laravel can cache configuration files, routes and events. Using the OptimizedAppCheck you can make sure these things are actually cached.
Here's how you can register the check.
use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\OptimizedAppCheck;
Health::checks([
OptimizedAppCheck::new(),
]);
This check will pass if the config, routes and events are cached.
Should this check fail for your app, then you should consider adding these commands to your deployment procedure
php artisan optimize # will cache config and routes
php artisan event:cache # will cache events
By default, the check will make sure that config, routes and events are cached. If you only want to check certain caches, you can call the checkConfig, checkRoutes and checkEvents methods. In this example, we'll only check for cached config and routes.
use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\OptimizedAppCheck;
Health::checks([
OptimizedAppCheck::new()
->checkConfig()
->checkRoutes(),
]);
How can I help you explore Laravel packages today?