PHP code example of aionphp / aion

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

    

aionphp / aion example snippets




namespace App\Providers;

use Aion\Facades\Aion;
use App\Console\Commands\CleanupOrders;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\ServiceProvider;

final class AionServiceProvider extends ServiceProvider
{
    public function boot(Schedule $schedule): void
    {
        Aion::register(
            key: 'orders.cleanup',
            event: $schedule
                ->command(CleanupOrders::class)
                ->dailyAt('03:00')
                ->withoutOverlapping()
                ->onOneServer(),
            label: 'Clean up orders',
            description: 'Clean up expired order state.',
        );
    }
}

use Aion\Facades\Aion;
use Illuminate\Http\Request;

Aion::viewUsing(
    fn (Request $request): bool =>
        $request->user()?->can('viewScheduler') ?? false,
);

Aion::manageUsing(
    fn (Request $request): bool =>
        $request->user()?->can('manageScheduler') ?? false,
);

return [
    'dashboard' => env('AION_DASHBOARD_ENABLED', true),
    'domain' => env('AION_DOMAIN'),
    'path' => env('AION_PATH', 'aion'),
    'middleware' => ['web'],
    'database' => [
        'connection' => env('AION_DB_CONNECTION'),
    ],
    'trim' => [
        'runs' => 10080, // minutes
        'incomplete_runs' => null, // null preserves running/incomplete rows
    ],
    'output' => [
        'max_bytes' => 1024 * 1024,
    ],
];

use Aion\Facades\Aion;

Aion::putOverride('orders.cleanup', cron: '0 4 * * *', enabled: false);
Aion::clearOverride('orders.cleanup');
bash
composer aion:install
php artisan migrate
bash
php artisan vendor:publish --provider="Aion\AionServiceProvider" --tag=aion-assets --force
bash
php artisan aion:prune
php artisan aion:prune --batch=500