PHP code example of mfrost503 / billow

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

    

mfrost503 / billow example snippets


$dropletBody = [
    'name' => 'My New Droplet',
    'region' => 'nyc2',
    'size' => '40gb',
    'image' => 'ubuntu-14-04-x64',
    'ssh_keys' => ['public key content'],
    'backups' => true,
    'ipv6' => true,
    'private_networking' => true,
    'user_data' => 'meta data to be associated with the droplet'
];


use Billow\DropletService;

$headers = ['Authorization' => 'Bearer xxxxxxxxx'];

// assuming the body of the request is the same as above
$dropletService = new DropletService();
$response = $dropletService->create($dropletBody, $headers);


use Billow\DropletService;

$headers = [
    'Authorization' => 'Bearer xxxxxxx'
];

$dropletId = 123456;

$dropletService = new DropletService();
$droplet = $dropletService->retrieve($dropletId, $headers);

echo $droplet->toJSON();


use Billow\DropletService;
use Billow\Actions\EnableBackups;

$headers = [
    'Authorization' => 'Bearer xxxxxxxx'
];
$enableBackups = new EnableBackups();
$dropletId = 123456;

$dropletService = new DropletService();
$droplet = $dropletService->retrieve($dropletId);

$response = $dropletService->performAction($droplet, $enableBackups, $headers);


use Billow\DropletService;
use Billow\Actions\Rename;

$headers = [
    'Authorization' => 'Bearer xxxxxxxx'
];
$rename = new Rename('my-renamed-droplet');
$dropletId = 123456;

$dropletService = new DropletService();
$droplet = $dropletService->retrieve($dropletId, $headers);

$response = $dropletService->performAction($droplet, $rename, $headers);