PHP code example of securitydiscovery / laravel-fly-machines
1. Go to this page and download the library: Download securitydiscovery/laravel-fly-machines 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/ */
securitydiscovery / laravel-fly-machines example snippets
// config for SecurityDiscovery/LaravelFlyMachines
return [
'proto' => env('FLY_API_PROTO', 'http'),
// The endpoint to the Fly machines API.
'endpoint' => env('FLY_API_HOSTNAME', '127.0.0.1:4280'),
// The token to authenticate to the API.
'token' => env('FLY_API_TOKEN'),
];
use SecurityDiscovery\LaravelFlyMachines\Facades\LaravelFlyMachines as FlyMachines;
FlyMachines::machines('my-fly-app')->list()
FlyMachines::machines('my-fly-app')->launch(machine: $config)
FlyMachines::machines('my-fly-app')->update(machineId: "machineId", machine: $config, nonce: "nonce")
FlyMachines::machines('my-fly-app')->get(machineId: "machineId")
FlyMachines::machines('my-fly-app')->stop(machineId: "machineId")
FlyMachines::machines('my-fly-app')->start(machineId: "machineId")
FlyMachines::machines('my-fly-app')->signal(machineId: "machineId", signal: 9)
FlyMachines::machines('my-fly-app')->kill(machineId: "machineId")
FlyMachines::machines('my-fly-app')->restart(machineId: "machineId", forceStop: true, timeout: 10, signal: 9)
FlyMachines::machines('my-fly-app')->findLease(machineId: "machineId")
FlyMachines::machines('my-fly-app')->acquireLease(machineId: "machineId", ttl: 30)
FlyMachines::machines('my-fly-app')->releaseLease(machineId: "machineId", nonce: "nonce")
FlyMachines::machines('my-fly-app')->releaseLease(machineId: "machineId", instanceId: "instanceId", state: "started", timeout: 30)
FlyMachines::machines('my-fly-app')->destroy(machineId: "machineId", kill: true)
use SecurityDiscovery\LaravelFlyMachines\Facades\LaravelFlyMachines as FlyMachines;
use SecurityDiscovery\LaravelFlyMachines\Helpers\Machine;
$machineConfig = Machine();
$machine = FlyMachines::machines('my-fly-app')
->launch(
Machine::builder()
->image(image: 'registry-1.docker.io/flyio/postgres:14.4')
->toArray()
);
use SecurityDiscovery\LaravelFlyMachines\Facades\LaravelFlyMachines as FlyMachines;
$machine = FlyMachines::machines('my-fly-app')->launch([
'config' => [
'image' => 'registry-1.docker.io/flyio/postgres:14.4',
],
'region' => 'fra',
]);
use SecurityDiscovery\LaravelFlyMachines\Facades\LaravelFlyMachines as FlyMachines;
use SecurityDiscovery\LaravelFlyMachines\Helpers\Machine;
$machineConfig = Machine::builder()
->image(image: 'my.registry.io/a/b:14.4') // Required
->init( // Optional
entrypoint: ['/bin/sh'],
exec: ['exec'],
cmd: ['cmd'],
tty: false
)
->retries( // Optional
max_retries: 3,
policy: 'on-failure'
)
->mount( // Optional
volume_id: 'vol_123',
path: '/data'
)
->env(name: 'NAME_1', value: 'VALUE_1') // Optional
->env(name: 'NAME_2', value: 'VALUE_2') // Optional
->auto_destroy(auto_destroy: True) // Optional
->name(name: 'my_machine') // Optional
->schedule(schedule: 'daily') // Optional
->region(region: 'fra') // Optional
->size(size: 'shared-cpu-1x' ) // Optional | WARNING: Use 'guest' or 'size'
->guest( // Optional
cpus: 1,
memory_mb: 2*256,
cpu_kind: 'shared',
kernel_args: []
)
->process() // TODO: Document this
->toArray();
bash
php artisan vendor:publish --tag="fly-machines-config"