PHP code example of deliciousbrains / spinupwp-php-sdk

1. Go to this page and download the library: Download deliciousbrains/spinupwp-php-sdk 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/ */

    

deliciousbrains / spinupwp-php-sdk example snippets


$spinupwp = new SpinupWp\SpinupWp('API_TOKEN');

// Return a collection of servers
$servers = $spinupwp->servers->list();

// Return a single server
$server = $spinupwp->servers->get($serverId);

// Create and return a new server 
$server = $spinupwp->servers->create([]);

// Create and return a new custom server 
$server = $spinupwp->servers->createCustom([]);

// Delete a server
$eventId = $spinupwp->servers->delete($serverId, $deleteOnProvider);

// Reboot a server
$eventId = $spinupwp->servers->reboot($serverId);

// Restart the Nginx service on a server
$eventId = $spinupwp->servers->restartNginx($serverId);

// Restart the Redis service on a server
$eventId = $spinupwp->servers->restartRedis($serverId);

// Restart all versions of the PHP-FPM service installed on a server
$eventId = $spinupwp->servers->restartPhp($serverId);

// Restart the MySQL or MariaDB service on a server
$eventId = $spinupwp->servers->restartMysql($serverId);

// Return a collection of this server's sites
$sites = $server->sites();

// Delete the current server
$server->delete($deleteOnProvider);

// Reboot the current server
$server->reboot();

// Restart the Nginx service on the current server
$server->restartNginx();

// Restart the Redis service on the current server
$server->restartRedis();

// Restart all versions of the PHP-FPM service installed on the current server
$server->restartPhp();

// Restart the MySQL or MariaDB service on the current server
$server->restartMysql();

// Return a collection of sites
$sites = $spinupwp->sites->list();

// Return a single site
$site = $spinupwp->sites->get($siteId);

// Create and return a new site
$site = $spinupwp->sites->create($serverId, []);

// Delete a site
$eventId = $spinupwp->sites->delete($siteId);

// Run a git deployment
$eventId = $spinupwp->sites->gitDeploy($siteId);

// Purge a site's page cache
$eventId = $spinupwp->sites->purgePageCache($siteId);

// Purge a site's object cache
$eventId = $spinupwp->sites->purgeObjectCache($siteId);

// Reset a site's file permissions
$eventId = $spinupwp->sites->correctFilePermissions($siteId);

// Enable HTTPS
$eventId = $spinupwp->sites->enableHttps($siteId, ['type' => 'webroot']);

// Update HTTPS settings
$eventId = $spinupwp->sites->updateHttps($siteId, [
    'type' => 'custom',
    'certificate' => '-----BEGIN CERTIFICATE-----...',
    'private_key' => '-----BEGIN PRIVATE KEY-----...',
]);

// Disable HTTPS
$eventId = $spinupwp->sites->disableHttps($siteId);

// Update PHP version
$eventId = $spinupwp->sites->updatePhpSettings($siteId, ['php_version' => '8.3']);

// Enable the SpinupWP subdomain
$eventId = $spinupwp->sites->enableSpinupwpSubdomain($siteId);

// Disable the SpinupWP subdomain
$eventId = $spinupwp->sites->disableSpinupwpSubdomain($siteId);

// List additional domains
$domains = $spinupwp->sites->listDomains($siteId);

// Add an additional domain
$domain = $spinupwp->sites->addDomain($siteId, [
    'domain' => 'www.turnipjuice.media',
    'redirect' => [
        'enabled' => true,
    ],
]);

// Update an additional domain
$domain = $spinupwp->sites->updateDomain($siteId, $domainId, [
    'redirect' => [
        'enabled' => true,
        'type' => 301,
        'destination' => 'turnipjuice.media',
    ],
]);

// Delete an additional domain
$eventId = $spinupwp->sites->deleteDomain($siteId, $domainId);

// Delete the current site
$site->delete();

// Run a git deployment
$site->gitDeploy();

// Purge a site's page cache
$site->purgePageCache();

// Purge a site's object cache
$site->purgeObjectCache();

// Reset a site's file permissions
$site->correctFilePermissions();

// Enable HTTPS
$site->enableHttps(['type' => 'webroot']);

// Update HTTPS settings
$site->updateHttps(['type' => 'custom', 'certificate' => '...', 'private_key' => '...']);

// Disable HTTPS
$site->disableHttps();

// Update PHP version
$site->updatePhpSettings(['php_version' => '8.3']);

// Enable the SpinupWP subdomain
$site->enableSpinupwpSubdomain();

// Disable the SpinupWP subdomain
$site->disableSpinupwpSubdomain();

// List additional domains
$site->listDomains();

// Add an additional domain
$site->addDomain(['domain' => 'www.turnipjuice.media']);

// Update an additional domain
$site->updateDomain($domainId, ['redirect' => ['enabled' => true]]);

// Delete an additional domain
$site->deleteDomain($domainId);

// Return a collection of events
$events = $spinupwp->events->list();

// Return a single event
$event = $spinupwp->events->get($eventId);

// Return SpinupWP's SSH Public Key
$key = $spinupwp->sshKeys->get();

$servers = $spinupwp->servers->list();

// Return an array of all servers
$servers->toArray();

// Return the total number of servers
$servers->count();

// Lazily iterate over all servers
foreach ($servers as $server) {
    // Do something with $server
}
bash
composer