Introducing Cloudways API PHP-SDK Built By Our Community of Clients

by Ahmed Khan  December 5, 2016

Application Programming Interface or API has become the latest “in” thing in the development world. Regardless of the language or the platform, APIs are used to decrease development time and headaches.

Almost every major platform and service providers now offers a set of APIs to accelerate development time for apps based on the platforms. As an example, take the case of Google. Almost every product in Google ecosystem has its own API that offers seamless integration of a particular service in a third-party product.

Cloudways API PHP SDK

Cloudways released API for its platform some time ago. This API allows developers to create apps upon the robust Cloudways platform. In a comprehensive series on Cloudways API, I have covered several application scenarios such as  creating a Slack Chat Bot with Cloudways API, connecting CloudwaysBot with Asana to create tasks, getting Alerts on SMS using Twilio, and sending CloudwaysBot notification to Trello. Refer to the complete list for more topics.

A common feature of these posts is the use of Guzzle and CURL for connecting to the Cloudways API. For some users, the use of these components offers a sizeable challenge. To make things easier for everyone, a client of Cloudways has built a PHP-SDK for Cloudways API. Developers only need to install the PHP-SDK via composer, clone it from bitbucket or download the repository and then connect with Cloudways API.

Where to Get it?

The community powered Cloudways API PHP-SDK is available on Bitbucket under MIT license. If you would like to contribute to the project, feel free to fork it.

Disclaimer: Cloudways doesn’t officially maintain this SDK, it is built and maintained by our clients.

Installing Cloudways API PHP-SDK

Installing PHP-SDK is very straightforward:

  • Create a new file in the root directory and name it composer.json. Paste the following code in it.

    Next, run the following command in your terminal.

    install using composer
    Alternatively, you can directly install it via terminal using the following command

    installing using composer require
  • The second method is to clone it using Git.

    git clone
    Once it is installed, move to Cloudways API SDK directory and run composer install so that all required dependencies are installed.

    composer install

Now that PHP-SDK is installed on the server, I will now use it to perform several server operations.

Working With Cloudways API PHP-SDK

I will start with getting the list of all cloud providers using Cloudways API PHP-SDK.

Create a new file in the root directory and name it index.php. Now, paste the following code in it.

I will now explain the above code step by step.

First, I included composer autoload and then the Cloudways Lists namespace.

Next, I created the object Lists, and set up email and the API key. Once it is set, I called getCloudProviders() to get the list of all the Cloudways cloud providers. Once the code is executed, the output would be:

result

This is just a very brief introduction of the Cloudways PHP-SDK. The SDK could be used to setup all projects based on Cloudways API.

Conclusion

Using PHP-SDK, you can connect with all the services mentioned in Cloudways API documentation. If you discover a bug, feel free to tell us or fork it to remove the bug and become a contributor! You are also welcome to discuss the SDK in the comments below.

Start Creating Web Apps on Managed Cloud Servers Now!

Easy Web App Deployment for Agencies, Developers and E-Commerce Industry

About Ahmed Khan

Ahmed was a PHP community expert at Cloudways - A Managed PHP Hosting Cloud Platform. He is a software engineer with extensive knowledge in PHP and SEO. He loves watching Game of Thrones is his free time. Follow Ahmed on Twitter to stay updated with his works. You can email him at ahmed.khan@cloudways.com

Stay Connected:

You Might Also Like...