Cloud Zone is brought to you in partnership with:

Open source enthusiast specializing on mobile applications and social application development on top of Facebook app development platform. An amateur photographer and father of two sons. Administrator of phpexperts, the largest php user group in Bangladesh having more than 2900 members. Hasin is a DZone MVB and is not an employee of DZone and has posted 16 posts at DZone. You can read more from them at their website. View Full User Profile

OpenShift PHP Rest Client Library

  • submit to reddit

I have been working whole day today on writing this rest client library for php developers. OpenShift is a fantastic Polyglot PaaS (Platform-as-a-Service). To perform various operations with your openshift account you need to use their command line tool “rhc” (a gem, requires ruby). Their web based admin panel is good for starters, but you need to master the rhc for other essential tasks, for example to add a domain alias or to start/stop/restart your application.

This OpenShift-PHP-Client library can directly invoke their rest api and makes it easier for you if you are a PHP developer. This application is in a good stage at this moment and you can do everything with domains, applications and cartridges.

How to use this library? Firxt check it out from it’s github repo located at Then see the source code of the example.php. The example contains the bare minimum, you can actually do a lot of other things with these Domain, Application and Cartridge object. To understand the scope, feel free to check their source code as well :)

$username = "YourUsername";
$password = "YourPassword";
$openshift = new OpenShift($username,$password);
// Create a New Domain 
$data = $openshift->getDomainManager()->createDomain("osphp");

// List Domains 
$data = $openshift->getDomainManager()->getDomains();

// Rename the Domain
$data = $openshift->getDomainManager()->getDomain("osphp")->updateName("moonlander") ;

// Create a Zend 5.6 App Container 
$data = $openshift->getDomainManager()->getDomain("osphp")->createApplication("restclient","zend-5.6");

// Get all Applications 
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplications();

// Get Application Details
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->getDetails();

// Stop an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->stop(); 

// Start an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->start(); 

// Restart an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->restart(); 

// Reload an Application
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->reload(); 

// Add an Alias
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->addAlias("");

// Remove an Alias
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->removeAlias("");

Add a MySQL Cartridge
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->addCartridge("mysql-5.1");

// Delete a MySQL Cartridge
$data = $openshift->getDomainManager()->getDomain("osphp")->getApplication("restclient")->getCartridge("mysql-5.1")->delete();

// There are many other methods supported by applications, domains and the cartridges. For details, check their source code. 

OpenShift PHP Client library is released under MIT License. I am working continuously to add more features to it.


Published at DZone with permission of Hasin Hayder, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)