Skip to content

Report module health with the actuator

At the end, /actuator/health reports which modules are enabled and returns DOWN if an enabled module is missing from disk. Modules can also register their own health checks on the same endpoint.

This integration uses nwidart/laravel-actuator (^1.1), which is optional. For endpoint setup and show_details options, see the Laravel Actuator documentation.

Terminal window
composer require nwidart/laravel-actuator

Once installed, Laravel Modules registers a modules health indicator automatically. No configuration edit is required.

When show_details allows it (for example ACTUATOR_HEALTH_SHOW_DETAILS=always), the modules indicator lists each module and its enabled status:

{
"modules": {
"Blog": { "enabled": true },
"Shop": { "enabled": false }
}
}

The indicator reports UP when every enabled module has its module.json on disk. It reports DOWN (HTTP 503) when an enabled module is missing from disk, and attaches an error to that module’s entry. To resolve a DOWN status, restore the module folder, remove its entry from modules_statuses.json, or set it to false.

See Actuator integration for full indicator behavior, including long-lived processes and custom activators.

  1. Generate the health indicator class.

    Terminal window
    php artisan module:make-health-indicator PaymentsHealthIndicator Blog

    This creates Modules/Blog/app/Health/PaymentsHealthIndicator.php.

  2. Implement health() to return a Health status (Health::up(), Health::down(), Health::outOfService(), or Health::unknown()). Any thrown exception is reported as DOWN.

    Modules/Blog/app/Health/PaymentsHealthIndicator.php
    <?php
    namespace Modules\Blog\Health;
    use Nwidart\Actuator\Health\Health;
    use Nwidart\Actuator\Health\HealthIndicator;
    class PaymentsHealthIndicator implements HealthIndicator
    {
    public function health(): Health
    {
    return Health::up(['provider' => 'reachable']);
    }
    }
  3. Register the indicator in the $healthIndicators property of your module service provider (extending ModuleServiceProvider).

    Modules/Blog/app/Providers/BlogServiceProvider.php
    protected array $healthIndicators = [
    'payments' => \Modules\Blog\Health\PaymentsHealthIndicator::class,
    'queue' => [\Modules\Blog\Health\QueueHealthIndicator::class, ['connection' => 'blog']],
    ];

Each entry is either a class name or [class, [constructor arguments]], resolved through the container. The package registers each indicator as module:{lowercase module name}:{key} (for example module:blog:payments and module:blog:queue).

  • Disabled modules register no indicators.
  • An indicator with the same name in config/actuator.php takes precedence.
  • Without nwidart/laravel-actuator installed, $healthIndicators is ignored.

Set modules.actuator.enabled to false in config/modules.php to disable both the modules indicator and all module $healthIndicators:

config/modules.php
'actuator' => [
'enabled' => false,
],

This affects health indicators only. The modules actuator endpoint stays registered; see Expose the modules on the actuator.

Health indicators register during boot, so php artisan config:cache snapshots them. Re-run php artisan config:cache after enabling or disabling a module, changing $healthIndicators, or toggling modules.actuator.enabled.

  • An invalid module.json or unloadable module service provider halts application boot with HTTP 500 before /actuator/health can run. Monitor your application’s HTTP status separately.
  • A nonexistent class in $healthIndicators causes /actuator/health to fail with HTTP 500 (BindingResolutionException). Verify class names after registering them.

Request the health endpoint (with ACTUATOR_HEALTH_SHOW_DETAILS=always in local development):

Terminal window
curl -H 'Accept: application/json' http://127.0.0.1:8000/actuator/health

The JSON response includes the modules component and any module:blog:* components you registered. You can also query one component directly at /actuator/health/module:blog:payments.