PHP code example of themsaid / forge-sdk
1. Go to this page and download the library: Download themsaid/forge-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/ */
themsaid / forge-sdk example snippets
$forge = new Laravel\Forge\Forge(TOKEN_HERE);
$servers = $forge->servers();
$server = $forge->server(SERVER_ID_HERE);
$server = $forge->createServer([
"provider"=> ServerProviders::DIGITAL_OCEAN,
"credential_id"=> 1,
"name"=> "test-via-api",
"type"=> ServerTypes::APP,
"size"=> "01",
"database"=> "test123",
"database_type" => InstallableServices::POSTGRES,
"php_version"=> InstallableServices::PHP_71,
"region"=> "ams2"
]);
$forge->createSite(SERVER_ID, [SITE_PARAMETERS]);
$forge->createSite(SERVER_ID, [SITE_PARAMETERS], false);
$forge->setTimeout(120)->createSite(SERVER_ID, [SITE_PARAMETERS]);
$forge->user();
$forge->servers();
$forge->server($serverId);
$forge->createServer(array $data);
$forge->updateServer($serverId, array $data);
$forge->deleteServer($serverId);
$forge->rebootServer($serverId);
// Server access
$forge->revokeAccessToServer($serverId);
$forge->reconnectToServer($serverId);
$forge->reactivateToServer($serverId);
$server->update(array $data);
$server->delete();
$server->reboot();
$server->revokeAccess();
$server->reconnect();
$server->reactivate();
$server->rebootMysql();
$server->stopMysql();
$server->rebootPostgres();
$server->stopPostgres();
$server->rebootNginx();
$server->stopNginx();
$server->installBlackfire(array $data);
$server->removeBlackfire();
$server->installPapertrail(array $data);
$server->removePapertrail();
$server->enableOPCache();
$server->disableOPCache();
$server->phpVersions();
$server->installPHP($version);
$server->updatePHP($version);
$forge->keys($serverId);
$forge->sshKey($serverId, $keyId);
$forge->createSSHKey($serverId, array $data, $wait = true);
$forge->deleteSSHKey($serverId, $keyId);
$sshKey->delete();
$forge->jobs($serverId);
$forge->job($serverId, $jobId);
$forge->createJob($serverId, array $data, $wait = true);
$forge->deleteJob($serverId, $jobId);
$job->delete();
$forge->events();
$forge->events($serverId);
// MySQL
$forge->rebootMysql($serverId);
$forge->stopMysql($serverId);
// Postgres
$forge->rebootPostgres($serverId);
$forge->stopPostgres($serverId);
// Nginx
$forge->rebootNginx($serverId);
$forge->stopNginx($serverId);
$forge->siteNginxFile($serverId, $siteId);
$forge->updateSiteNginxFile($serverId, $siteId, $content);
// Blackfire
$forge->installBlackfire($serverId, array $data);
$forge->removeBlackfire($serverId);
// Papertrail
$forge->installPapertrail($serverId, array $data);
$forge->removePapertrail($serverId);
// OPCache
$forge->enableOPCache($serverId);
$forge->disableOPCache($serverId);
$forge->daemons($serverId);
$forge->daemon($serverId, $daemonId);
$forge->createDaemon($serverId, array $data, $wait = true);
$forge->restartDaemon($serverId, $daemonId, $wait = true);
$forge->deleteDaemon($serverId, $daemonId);
$daemon->restart($wait = true);
$daemon->delete();
$forge->firewallRules($serverId);
$forge->firewallRule($serverId, $ruleId);
$forge->createFirewallRule($serverId, array $data, $wait = true);
$forge->deleteFirewallRule($serverId, $ruleId);
$rule->delete();
$forge->sites($serverId);
$forge->site($serverId, $siteId);
$forge->createSite($serverId, array $data, $wait = true);
$forge->updateSite($serverId, $siteId, array $data);
$forge->refreshSiteToken($serverId, $siteId);
$forge->deleteSite($serverId, $siteId);
// Add Site Aliases
$forge->addSiteAliases($serverId, $siteId, array $aliases);
// Environment File
$forge->siteEnvironmentFile($serverId, $siteId);
$forge->updateSiteEnvironmentFile($serverId, $siteId, $content);
// Site Repositories and Deployments
$forge->installGitRepositoryOnSite($serverId, $siteId, array $data, $wait = false);
$forge->updateSiteGitRepository($serverId, $siteId, array $data);
$forge->destroySiteGitRepository($serverId, $siteId, $wait = false);
$forge->createSiteDeployKey($serverId, $siteId);
$forge->destroySiteDeployKey($serverId, $siteId);
$forge->siteDeploymentScript($serverId, $siteId);
$forge->updateSiteDeploymentScript($serverId, $siteId, $content);
$forge->enableQuickDeploy($serverId, $siteId);
$forge->disableQuickDeploy($serverId, $siteId);
$forge->deploySite($serverId, $siteId, $wait = false);
$forge->resetDeploymentState($serverId, $siteId);
$forge->siteDeploymentLog($serverId, $siteId);
$forge->deploymentHistory($serverId, $siteId);
$forge->deploymentHistoryDeployment($serverId, $siteId, $deploymentId);
$forge->deploymentHistoryOutput($serverId, $siteId, $deploymentId);
// PHP Version
$forge->changeSitePHPVersion($serverId, $siteId, $version);
// Installing Wordpress
$forge->installWordPress($serverId, $siteId, array $data);
$forge->removeWordPress($serverId, $siteId);
// Installing phpMyAdmin
$forge->installPhpMyAdmin($serverId, $siteId, array $data);
$forge->removePhpMyAdmin($serverId, $siteId);
// Updating Node balancing Configuration
$forge->updateNodeBalancingConfiguration($serverId, $siteId, array $data);
$site->refreshToken();
$site->delete();
$site->installGitRepository(array $data, $wait = false);
$site->updateGitRepository(array $data);
$site->destroyGitRepository($wait = false);
$site->createDeployKey();
$site->destroyDeployKey();
$site->getDeploymentScript();
$site->updateDeploymentScript($content);
$site->enableQuickDeploy();
$site->disableQuickDeploy();
$site->deploySite($wait = false);
$site->resetDeploymentState();
$site->siteDeploymentLog();
$site->getDeploymentHistory();
$site->getDeploymentHistoryDeployment($deploymentId);
$site->getDeploymentHistoryOutput($deploymentId);
$site->installWordPress($data);
$site->removeWordPress();
$site->installPhpMyAdmin($data);
$site->removePhpMyAdmin();
$site->changePHPVersion($version);
$site->siteLog();
$site->deleteSiteLog();
$forge->workers($serverId, $siteId);
$forge->worker($serverId, $siteId, $workerId);
$forge->createWorker($serverId, $siteId, array $data, $wait = true);
$forge->deleteWorker($serverId, $siteId, $workerId);
$forge->restartWorker($serverId, $siteId, $workerId, $wait = true);
$worker->delete();
$worker->restart($wait = true);
$forge->securityRules($serverId, $siteId);
$forge->securityRule($serverId, $siteId, $ruleId);
$forge->createSecurityRule($serverId, $siteId, array $data);
$forge->deleteSecurityRule($serverId, $siteId, $ruleId);
$securityRule->delete();
$forge->webhooks($serverId, $siteId);
$forge->webhook($serverId, $siteId, $webhookId);
$forge->createWebhook($serverId, $siteId, array $data);
$forge->deleteWebhook($serverId, $siteId, $webhookId);
$webhook->delete();
$forge->executeSiteCommand($serverId, $siteId, array $data);
$forge->listCommandHistory($serverId, $siteId);
$forge->getSiteCommand($serverId, $siteId, $commandId);
$forge->certificates($serverId, $siteId);
$forge->certificate($serverId, $siteId, $certificateId);
$forge->createCertificate($serverId, $siteId, array $data, $wait = true);
$forge->deleteCertificate($serverId, $siteId, $certificateId);
$forge->getCertificateSigningRequest($serverId, $siteId, $certificateId);
$forge->installCertificate($serverId, $siteId, $certificateId, array $data, $wait = true);
$forge->activateCertificate($serverId, $siteId, $certificateId, $wait = true);
$forge->obtainLetsEncryptCertificate($serverId, $siteId, $data, $wait = true);
$certificate->delete();
$certificate->getSigningRequest();
$certificate->install($wait = true);
$certificate->activate($wait = true);
$forge->nginxTemplates($serverId);
$forge->nginxDefaultTemplate($serverId);
$forge->nginxTemplate($serverId, $templateId);
$forge->createNginxTemplate($serverId, array $data);
$forge->updateNginxTemplate($serverId, $templateId, array $data);
$forge->deleteNginxTemplate($serverId, $templateId);
$nginxTemplate->update(array $data);
$nginxTemplate->delete();
$forge->databases($serverId);
$forge->database($serverId, $databaseId);
$forge->createDatabase($serverId, array $data, $wait = true);
$forge->updateDatabase($serverId, $databaseId, array $data);
$forge->deleteDatabase($serverId, $databaseId);
$forge->syncDatabases($serverId);
// Users
$forge->databaseUsers($serverId);
$forge->databaseUser($serverId, $userId);
$forge->createDatabaseUser($serverId, array $data, $wait = true);
$forge->updateDatabaseUser($serverId, $userId, array $data);
$forge->deleteDatabaseUser($serverId, $userId);
$database->update(array $data);
$database->delete();
$databaseUser->update(array $data);
$databaseUser->delete();
$forge->recipes();
$forge->recipe($recipeId);
$forge->createRecipe(array $data);
$forge->updateRecipe($recipeId, array $data);
$forge->deleteRecipe($recipeId);
$forge->runRecipe($recipeId, array $data);
$recipe->update(array $data);
$recipe->delete();
$recipe->run(array $data);
$forge->backupConfigurations($serverId);
$forge->createBackupConfiguration($serverId, array $data);
$forge->updateBackupConfiguration($serverId, $backupConfigurationId, array $data);
$forge->backupConfiguration($serverId, $backupConfigurationId);
$forge->deleteBackupConfiguration($serverId, $backupConfigurationId);
$forge->restoreBackup($serverId, $backupConfigurationId, $backupId);
$forge->deleteBackup($serverId, $backupConfigurationId, $backupId);
$extendedConfig = $backupConfig->get(); // Load the databases also
$backupConfig->update(array $data);
$backupConfig->delete();
$backupConfig->restoreBackup($backupId);
$backupConfig->deleteBackup($backupId);
$backupConfig->delete();
$backupConfig->restore();
$forge->redirectRules($serverId, $siteId);
$forge->redirectRule($serverId, $siteId, $ruleId);
$forge->createRedirectRule($serverId, $siteId, array $data, $wait = true);
$forge->deleteRedirectRule($serverId, $siteId, $ruleId);
$redirectRule->delete();