PHP code example of allanzico / laravel-helios

1. Go to this page and download the library: Download allanzico/laravel-helios 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/ */

    

allanzico / laravel-helios example snippets


return [
    'enabled' => env('HELIOS_ENABLED', true),
    'path' => env('HELIOS_PATH', 'helios'),

    'middleware' => [
        'web',
        \Allanzico\LaravelHelios\Http\Middleware\Authorize::class,
    ],

    'allowed_environments' => ['local', 'testing'],
    'gate' => 'viewHelios',
    'strict_authorization' => true,

    'log_path' => storage_path('logs'),

    'watchers' => [
        'requests' => [
            'enabled' => env('HELIOS_REQUESTS_ENABLED', true),
            'slow_ms' => (float) env('HELIOS_SLOW_REQUEST_MS', 1000),
            'sample_rate' => (float) env('HELIOS_REQUEST_SAMPLE_RATE', 0.05),
        ],
        'queries' => [
            'enabled' => env('HELIOS_QUERIES_ENABLED', true),
            'slow_ms' => (float) env('HELIOS_SLOW_QUERY_MS', 100),
            'sample_rate' => (float) env('HELIOS_QUERY_SAMPLE_RATE', 0.0),
        ],
        'schedule' => [
            'enabled' => env('HELIOS_SCHEDULE_ENABLED', true),
            'allow_manual_runs' => env('HELIOS_ALLOW_MANUAL_SCHEDULE_RUNS', false),
            'manual_allowlist' => [],
        ],
    ],

    'actions' => [
        'run_scheduled_tasks' => env('HELIOS_ALLOW_MANUAL_SCHEDULE_RUNS', false),
        'retry_jobs' => env('HELIOS_ALLOW_JOB_RETRY', false),
        'forget_jobs' => env('HELIOS_ALLOW_JOB_FORGET', false),
        'clear_logs' => env('HELIOS_ALLOW_LOG_CLEAR', false),
        'purge_data' => env('HELIOS_ALLOW_PURGE_DATA', false),
    ],

    'security' => [
        'store_query_bindings' => env('HELIOS_STORE_QUERY_BINDINGS', false),
        'store_request_body' => env('HELIOS_STORE_REQUEST_BODY', false),
        'store_request_headers' => env('HELIOS_STORE_REQUEST_HEADERS', false),
        'show_health_meta' => env('HELIOS_SHOW_HEALTH_META', app()->environment(['local', 'testing'])),
    ],

    'health' => [
        'scheduler' => [
            'lookback_minutes' => (int) env('HELIOS_SCHEDULER_HEALTH_LOOKBACK_MINUTES', 1440),
            'grace_minutes' => (int) env('HELIOS_SCHEDULER_HEALTH_GRACE_MINUTES', 5),
        ],
        'redis' => [
            'enabled' => env('HELIOS_HEALTH_REDIS_ENABLED'),
        ],
        'environment' => [
            'expected' => env('HELIOS_HEALTH_EXPECTED_ENV'),
        ],
        'storage' => [
            'paths' => [
                storage_path('framework/cache'),
                storage_path('logs'),
            ],
        ],
    ],

    'retention_days' => (int) env('HELIOS_RETENTION_DAYS', 7),

    'error_tracking' => [
        'enabled' => env('HELIOS_ERROR_TRACKING_ENABLED', true),
        'group_by_line' => env('HELIOS_ERROR_GROUP_BY_LINE', false),
    ],
];

use Illuminate\Support\Facades\Gate;

Gate::define('viewHelios', fn ($user = null) => $user?->email === '[email protected]');

Gate::define('runHeliosTask', fn ($user = null) => $user?->isAdmin());
Gate::define('retryHeliosJob', fn ($user = null) => $user?->isAdmin());
Gate::define('forgetHeliosJob', fn ($user = null) => $user?->isAdmin());
Gate::define('clearHeliosLog', fn ($user = null) => $user?->isAdmin());
Gate::define('purgeHeliosData', fn ($user = null) => $user?->isAdmin());

use Allanzico\LaravelHelios\Models\HeliosRequest;
use Allanzico\LaravelHelios\Models\HeliosQuery;
use Allanzico\LaravelHelios\Models\HeliosJob;

// Delete old data
HeliosRequest::where('created_at', '<', now()->subDays(7))->delete();
HeliosQuery::where('created_at', '<', now()->subDays(7))->delete();
HeliosJob::where('started_at', '<', now()->subDays(7))->delete();
bash
php artisan migrate
bash
php artisan helios:sync-tasks
bash
cd playground
php artisan test
bash
# Publish config file
php artisan vendor:publish --tag=helios-config

# Publish views (for customization)
php artisan vendor:publish --tag=helios-views

# Publish migrations (if you want to modify them)
php artisan vendor:publish --tag=helios-migrations
bash
php artisan vendor:publish --tag=helios-config
bash
php artisan helios:prune
php artisan helios:prune --days=14
bash
   php artisan view:clear
   php artisan config:clear
   php artisan cache:clear
   
bash
   composer dump-autoload
   
bash
   php artisan migrate
   
bash
   php artisan view:clear
   
bash
   php artisan migrate