1. Go to this page and download the library: Download pxgamer/digitalocean-php 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/ */
pxgamer / digitalocean-php example snippets
use \pxgamer\DigitalOcean\Client;
$client = new Client();
// Use the specific classes as their short names
use \pxgamer\DigitalOcean;
// Create a new Client instance
$client = new DigitalOcean\Client();
$client->setAuthKey('API_KEY');
// Initialise a new instance of each class
$account = new DigitalOcean\Account($client);
$domains = new DigitalOcean\Domains($client);
$droplets = new DigitalOcean\Droplets($client);
$droplet = new DigitalOcean\Droplet($client);
/**
* This is passed into all other classes.
*/
use \pxgamer\DigitalOcean\Client;
$client = new Client();
$client->setAuthKey('API_KEY');
use \pxgamer\DigitalOcean\Account;
$account = new Account($client);
$account->getAccount();
use \pxgamer\DigitalOcean\Domains;
$domains = new Domains($client);
$domains->listDomains();
$domains->getDomain('example.com');
$domains->createDomain('example.com');
$domains->deleteDomain('example.com');
// Requires the Client class to be initialised
use \pxgamer\DigitalOcean\Droplets;
$droplets = new Droplets($client);
$droplets->listDroplets();
$droplets->listNeighbours();
// Requires the Client class to be initialised
use \pxgamer\DigitalOcean\Droplet;
$droplet = new Droplet($client);
$droplet->setDroplet('DROPLET_ID');
// Requires the droplet ID to be set
$droplet->getDroplet();
// Requires the droplet ID to be set
$droplet->deleteDroplet();
// Requires the droplet ID to be set
$droplet->listNeighbours();
// Requires the droplet ID to be set
$droplet->createSnapshot('SNAPSHOT-NAME');
// Requires the droplet ID to be set
$droplet->enableBackups();
// Requires the droplet ID to be set
$droplet->disableBackups();
// Requires the droplet ID to be set
$droplet->reboot();
// Requires the droplet ID to be set
$droplet->powerCycle();
// Requires the droplet ID to be set
$droplet->shutdown();
// Requires the droplet ID to be set
$droplet->powerOff();
// Requires the droplet ID to be set
$droplet->powerOn();
/**
* Requires the droplet ID to be set
*
* Attributes:
* - $size [string] (e.g. '1gb')
* - $increaseDiskSize [boolean] (e.g. false) - Determines whether this is a permanent resize or not
*/
$droplet->resize('1gb', false);
// Requires the droplet ID to be set
$droplet->passwordReset();
// Requires the droplet ID to be set
$droplet->rename('NEW_DROPLET_NAME');
// Requires the droplet ID to be set
$droplet->enableIPv6();
// Requires the droplet ID to be set
$droplet->enablePrivateNetworking();
bash
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.