1. Go to this page and download the library: Download lionix/digitalocean 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/ */
lionix / digitalocean example snippets
use Digitalocean\Services\DropletsService;
// 1. Dependency injection
public function index(DropletsService $droplets)
{
return $droplets->list();
}
// 2. Service facade
Droplets::list();
// 3. Global facade
Digitalocean::droplets()->list();
$response = Droplets::show(123);
if ($response['status_code'] !== 200) {
// e.g. ['id' => 'not_found', 'message' => 'The resource you requested could not be found.', 'status_code' => 404]
logger()->error($response['message']);
}
Snapshots::list(123); // snapshots of a droplet
Snapshots::all('droplet'); // all account snapshots, optionally 'droplet' or 'volume'
Snapshots::make(123, 'nightly'); // named "nightly-2026-01-01 00:00:00"
Snapshots::show($snapshotId);
Snapshots::destroy($snapshotId);
ReservedIps::list();
ReservedIps::store(['droplet_id' => 123]); // or ['region' => 'nyc3']
ReservedIps::assign('203.0.113.50', 456); // move the IP to another droplet (failover)
ReservedIps::unassign('203.0.113.50');
ReservedIps::show('203.0.113.50');
ReservedIps::destroy('203.0.113.50');