akondas/symfony-actuator-bundle
Install the package via Composer:
composer require vendor/package-name
Publish the configuration (if needed) and register the service provider in config/app.php under the providers array:
Vendor\PackageName\PackageServiceProvider::class,
The package provides two basic endpoints out of the box:
/health for a simple status response (e.g., {"status": "ok"})./info for package metadata (e.g., version, environment details).First Use Case:
Quickly integrate a /health endpoint for monitoring tools (e.g., Prometheus, UptimeRobot) or API gateways. Example:
// In routes/web.php or routes/api.php
Route::get('/health', [Vendor\PackageName\Http\Controllers\HealthController::class, 'check']);
Health Checks:
Vendor\PackageName\Http\Controllers\HealthController or binding a custom controller.public function check()
{
$status = ['status' => 'ok'];
if (!$this->database->connection()->getPdo()) {
$status['database'] = 'unreachable';
}
return response()->json($status);
}
health-checks config array:
'checks' => [
'database' => \Vendor\PackageName\Checks\DatabaseCheck::class,
],
Info Endpoint:
Vendor\PackageName\Http\Controllers\InfoController or binding a new controller.public function info()
{
return response()->json([
'version' => '1.0.0',
'environment' => app()->environment(),
'custom' => ['feature_flag' => config('app.feature_flag')],
]);
}
/health endpoint for circuit breakers or load balancers./info for dynamic metadata in dashboards (e.g., Grafana).throttle or auth middleware if needed:
Route::middleware(['throttle:60'])->get('/health', [HealthController::class, 'check']);
Endpoint Collisions:
/health and /info routes don’t conflict with existing routes. Use route model binding or middleware to namespace them (e.g., prefix with /api/v1).Route::prefix('api/v1')->group(function () {
Route::get('/health', [HealthController::class, 'check']);
});
Performance:
/health (e.g., queries, external API calls). Keep responses lightweight for monitoring tools./info response if it includes static data:
return Cache::remember('package-info', 3600, function () {
return $this->infoPayload();
});
Configuration Overrides:
config/package-name.php for settings. Ensure the config file exists and is published:
php artisan vendor:publish --tag=package-name-config
Endpoint Not Found:
bootstrap/app.php or routes/web.php).php artisan route:list to confirm the routes exist.Custom Checks Failing:
health-checks config array for typos or missing dependencies (e.g., database drivers).APP_DEBUG=true) to log errors from custom checks.Custom Controllers:
$this->app->bind(
Vendor\PackageName\Http\Controllers\HealthController::class,
App\Http\Controllers\CustomHealthController::class
);
Dynamic Responses:
Vendor\PackageName\Contracts\HealthCheck interface to create reusable check logic:
class CustomCheck implements HealthCheck {
public function check(): array {
return ['status' => $this->evaluate()];
}
}
Localization:
lang config or using Laravel’s localization features:
'responses' => [
'health' => [
'ok' => __('package::health.ok'),
],
],
How can I help you explore Laravel packages today?