PHP Classes

Cloudways API Class: Manage servers and applications with CloudWays API

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 65 All time: 10,389 This week: 455Up
Version License PHP version Categories
cloudwaysapiclass 1.0.0MIT/X Consortium ...5.6PHP 5, Hosting
Description 

Author

This class can manage servers and applications with CloudWays API.

It can send HTTP requests to the CloudWays API Web server to perform several operations with servers hosted via the CloudWays platform.

Currently it can get all the servers of an account, delete a server, get and set the settings of a server, get server applications, add or delete an application.

Innovation Award
PHP Programming Innovation award nominee
May 2017
Number 7
Cloud hosting services are often used by Web applications that need to be able to quickly scale the number of servers used to handle the current load of a Web application.

Cloudways is one provider that can manage servers and installed applications of cloud hosting services. This class provides means to control those servers using Cloudways API.

Manuel Lemos
Picture of Shahroze Nawaz
  Performance   Level  
Name: Shahroze Nawaz <contact>
Classes: 1 package by
Country: Pakistan Pakistan
Age: ???
All time rank: 447558 in Pakistan Pakistan
Week rank: 180 Up2 in Pakistan Pakistan Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
include 'CloudwaysApi.php';
$api_key = 'Your_api_key';
$email = 'Your_Cloud_email';
$cw_api = new CloudwaysAPI($email,$api_key);
$servers = $cw_api->getServers();
$settings = $cw_api->getServerSettings($serverId);
$applications = $cw_api->getApplications();
$addapp= $cw_api->addApplication($serverid, $application, $app_version, $app_name);
$delapp= $cw_api->deleteApplication($serverid, $applicationid);
$delserver = $cw_api->deleteServer($serverId);

echo
"<pre>";
var_dump($servers);
echo
"</pre>";

//for updating server settings

foreach($servers->servers as $serverinfo){}
   
$server_settings = $cw_api->get_servers_settings($serverinfo->id);
   
$success = null;
    if(isset(
$_POST['submit']))
    {
       
$server_id = $_POST['server_id'];
       
$date_timezone = $_POST['date_timezone'];
       
$display_errors = $_POST['display_errors'];
       
$apc_shm_size = $_POST['apc_shm_size'];
       
$execution_limit = $_POST['execution_limit'];
       
$memory_limit = $_POST['memory_limit'];
       
$max_input_vars = $_POST['max_input_vars'];
       
$max_input_time = $_POST['max_input_time'];
       
$mod_xdebug = $_POST['mod_xdebug'];
       
$upload_size = $_POST['upload_size'];
       
$error = null;
       
$result = $cw_api->set_servers_settings($server_id,$date_timezone,$display_errors,$apc_shm_size,$execution_limit,$memory_limit,$max_input_vars,$max_input_time,$mod_xdebug,$upload_size);
        if(
$result == [])
        {
           
$success["message"] = "Settings has been saved!";
        }
        else
        {
           
$success["message"] = "Kindly correct the above errors.";
        }
       
$Message = urlencode($success["message"]);
       
header('Location:index.php?Message='.$Message);
    }



  Files folder image Files (3)  
File Role Description
Plain text file CloudwaysApi.php Class Class source
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:65
This week:0
All time:10,389
This week:455Up