PHP Classes

PHP Cloudways API SDK: Manage sites hosted in Cloudways using its API

Recommend this page to a friend!
  Info   View files Documentation   View files View files (28)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 12 All time: 11,257 This week: 555Up
Version License PHP version Categories
cloudwaysapisdk 1.0The PHP License5Hosting
Description 

Author

This package can be used to manage sites hosted in Cloudways using its API.

It can send HTTP requests to the Cloudways API Web server to perform several types of requests. Currently it can:

- Manage hosted application DNS records
- Manage the access of Git repositories using SSH keys
- Manage integrations with other systems
- Manage the alerts of the current account
- Search in the knowledge base
- List the available server resources
- Manage hosted projects
- Manage SSL certificates and other security resources
- Manage hosting servers
- Manage the Varnish caching server

Picture of Ahmed Khan
Name: Ahmed Khan <contact>
Classes: 9 packages by
Country: Pakistan Pakistan
Age: ???
All time rank: 244934 in Pakistan Pakistan
Week rank: 416 Up8 in Pakistan Pakistan Up
Innovation award
Innovation award
Nominee: 3x

Documentation

A PHP-SDK for Cloudways API.

You can clone it to start working on it or use composer to install it.

Type the following command to install SDK using composer

$composer require ahmedkhan847/cloudwaysapiphpsdk

Or create a new file name it composer.json and paste the following code in it.

    {
    	"require": {
    		        "ahmedkhan847/cloudwaysapiphpsdk" : "1.0.0.x-dev"
    	    }
    }

Cloudways API PHP-SDK also provides you two function to check the status of operation id. The first is getOperation($operationid) which will return the result from which you have to extract whether the operation is completed. The second one is getOperationResult($operationid, $wait) which take the $operationid and $wait parameter (in seconds) and returns true when the operation is completed. If it reaches the maximum execution time for PHP, the code will stop and you need to run the function again.

To learn more about using it read the following guide: Possibilities of Cloudways API PHP-SDK.

Creating a New Server

#!php

<?php
require "vendor/autoload.php";

use Cloudways\Server\Server;

$server = new Server();
$server->SetEmail("ahmed.khan@cloudways.com");
$server->SetKey("gR1YywOMN2gG8L0FZC6Rd3QSsr0jlM");

$value['cloud'] = "do";
$value['region'] ="lon1";
$value['instance_type'] ="512MB";
$value['memory_size'] ="";
$value['application'] ="phpstack";
$value['app_version'] ="5.4";
$value['project_name'] ="";
$value['this->server_label'] ="abc";
$value['app_label'] ="abc";
$value['db_volume_size'] ="";
$value['data_volume_size'] ="";

$result = $server->create_server($value);

Using this SDK in Laravel

For laravel define email and api key in .env file

CW_EMAIL=ahmed.khan@cloudways.com
CW_API_KEY=gR1YywOMN2gG8L0FZC6Rd3QSsr0jlM

Then in your control add the namespace and start using it.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Cloudways\Lists\Lists;

class ApiController extends Controller
{
    /
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        $list = new Lists();
        $result = [];
        $result[] = $list->getServerRegions();
        $result[] = $list->getCloudProviders();
        $result[] = $list->getServerSizes();
        $result[] = $list->getApps();
        $result[] = $list->getPackages();
        $result[] = $list->getSettings();
        $result[] = $list->getBackupFrequencies();
        $result[] = $list->getCountries();
        $result[] = $list->getMonitorDurations();
        $result[] = $list->getMonitorTargets();
        return $result;
    }
}
?>

  Files folder image Files  
File Role Description
Files folder imageAPITestFiles (1 directory)
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  APITestFiles  
File Role Description
Files folder imageTest (11 files)

  Files folder image Files  /  APITestFiles  /  Test  
File Role Description
  Plain text file ApplicationManageTest.php Class Class source
  Plain text file ApplicationTest.php Class Class source
  Plain text file CloudwaysBotTest.php Class Class source
  Plain text file GitTest.php Class Class source
  Plain text file ListsTest.php Class Class source
  Plain text file ProjectTest.php Class Class source
  Plain text file SecurityTest.php Class Class source
  Plain text file ServerManageTest.php Class Class source
  Plain text file ServerServiceTest.php Class Class source
  Plain text file ServerTest.php Class Class source
  Plain text file VarnishTest.php Class Class source

  Files folder image Files  /  src  
File Role Description
Files folder imageCloudways (1 file, 9 directories)

  Files folder image Files  /  src  /  Cloudways  
File Role Description
Files folder imageApplication (1 file, 1 directory)
Files folder imageCloudwaysBot (1 file)
Files folder imageGit (1 file)
Files folder imageKbSearch (1 file)
Files folder imageLists (1 file)
Files folder imageProject (1 file)
Files folder imageSecurity (1 file)
Files folder imageServer (1 file, 2 directories)
Files folder imageVarnish (1 file)
  Plain text file Base.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Application  
File Role Description
Files folder imageManageApplication (1 file)
  Plain text file Application.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Application  /  ManageApplication  
File Role Description
  Plain text file ManageApplication.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  CloudwaysBot  
File Role Description
  Plain text file CloudwaysBot.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Git  
File Role Description
  Plain text file Git.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  KbSearch  
File Role Description
  Plain text file KbSearch.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Lists  
File Role Description
  Plain text file Lists.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Project  
File Role Description
  Plain text file Project.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Security  
File Role Description
  Plain text file Security.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Server  
File Role Description
Files folder imageManage (1 file)
Files folder imageService (1 file)
  Plain text file Server.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Server  /  Manage  
File Role Description
  Plain text file Manage.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Server  /  Service  
File Role Description
  Plain text file Service.php Class Class source

  Files folder image Files  /  src  /  Cloudways  /  Varnish  
File Role Description
  Plain text file Varnish.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:12
This week:0
All time:11,257
This week:555Up