PHP code example of sbasu / laravel-actuator

1. Go to this page and download the library: Download sbasu/laravel-actuator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sbasu / laravel-actuator example snippets


return [
    // URI prefix for all endpoints
    'path' => env('ACTUATOR_PATH', 'actuator'),

    // Middleware applied to actuator endpoints
    'middleware' => ['api'],

    // Enable/disable individual health indicators
    'indicators' => [
        'database' => true,
        'disk_space' => true,
        'cache' => true,
        'queue' => true,
    ],

    // Metrics collection settings
    'metrics' => [
        'enabled' => true,
        'sample_rate' => 1.0,
    ],

    // Show detailed health information in responses
    'show_details' => true,

    // Show environment variables (disabled by default for security)
    'show_env' => env('ACTUATOR_SHOW_ENV', false),

    // Log all actuator requests
    'log_access' => false,
];

'middleware' => ['api', 'auth:api'],

'middleware' => ['api', 'throttle:60,1'],

'middleware' => ['api', App\Http\Middleware\ActuatorAuth::class],
bash
php artisan vendor:publish --tag=actuator-config
bash
php artisan serve
bash
php artisan serve
dockerfile
FROM php:8.3-cli

COPY . /app
WORKDIR /app

RUN composer install

# Health check every 30s
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
  CMD curl -f http://localhost:8000/actuator/health || exit 1

CMD ["php", "artisan", "serve", "--host=0.0.0.0"]
bash
php artisan vendor:publish --tag=actuator-config
bash
php artisan vendor:publish --tag=actuator-config
bash
# Stop and restart
php artisan serve