October 20, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Create a PHP 5.3 Cloud Application, Page 3

  • April 2, 2013
  • By Octavia Andreea Anghel
  • Send Email »
  • More Articles »

This is the fastest and easiest method to create a PHP 5.3 cloud application. So, to accomplish this task all you need to do is:

1. open your OpenShift account

2. go on Create Application tab

3. select PHP from the list (figure 11):

Choosing PHP from the application types
Figure 11 - Choosing PHP from the application types

4. After you select PHP from the above list you should choose a web programming cartridge you want to use next. You may notice from the below figure that Zend Server 5.6, CakePHP, Drupal 7, WordPress 3.x and PHP 5.3 are the application types available for creating a PHP cloud application. You also have the opportunity to enable additional capabilities like databases, cron, metrics, and continuous build support after you create the application. (In the next section of this article we will add a database to this second application)

The available PHP cartridges for the cloud applications
Figure 12 - The available PHP cartridges for the cloud applications

We will choose to create a simple PHP 5.3 application; therefore we will choose PHP 5.3 application type. All we have to do next is to set a name for our application; we will name it secondExample, and press the Create Application button. That's it! In My Applications tab you should see now the new created application.

Clone the PHP Cloud Application into a Local Repository

To clone the cloud application, secondApplication, we will use the below command, which creates a local copy of the source code repository for you.

$ rhc git-clone secondExample

Cloning the secondExample cloud application and seeing its structure on our local repository
Figure 13 - Cloning the secondExample cloud application and seeing its structure on our local repository

Adding Cartridges

First, we need to check the available cartridges and for that, we need to use the below command, from command line:

$ rhc cartridge list

Listing all the available cartridges
Figure 14 - Listing all the available cartridges

You may notice this is a complete list of available cartridges, not only for PHP.

As I said in the previous section, we can add specific features to our application; in our case we will add a database. For this, we need first to add the mysql-5.1 cartridge. There are two methods to add mysql-5.1 cartridge:

1. from command line, using the below command:

$ rhc cartridge add mysql-5.1

Adding the mysql-5.1 cartridge to application secondExample in command line
Figure 15 - Adding the mysql-5.1 cartridge to application secondExample in command line

2. directly on cloud, by pressing the Add Cartridge button:

Adding the mysql-5.1 cartridge to application secondExample on cloud
Figure 16 - Adding the mysql-5.1 cartridge to application secondExample on cloud

We will get a list with the available cartridges for our PHP application, secondExample:

 Available PHP cartridges
Figure 17 - Available PHP cartridges

Select MySQL database 5.1 and then press the Add cartridge button. You will receive a user and a password and you should make a note of them or make a print screen figure containing them, because you will need them later when you populate your database:

Confirmation message that MySQL cartridge was successfully added to your application
Figure 18 - Confirmation message that MySQL cartridge was successfully added to your application

Now, that we have added the mysql-5.1 cartridge, we can add the phpMyAdmin 3.4 cartridge, which is a web based MySQL admin tool and for that requires that MySQL cartridge should be installed first. So, select the phpMyAdmin 3.4 cartridge and press the Add Cartridge button. This is the message you will get after adding phpMyAdmin cartridge:

Confirmation message that phpMyAdmin cartridge was successfully added to your application
Figure 19 - Confirmation message that phpMyAdmin cartridge was successfully added to your application

Notice that you will also receive a URL and we will use that URL to connect to our database, through the phpMyAdmin MySQL admin tool. Opening this URL into a new browser page, you will get an Authentication Required window, where you should introduce the user and password received previously (when I said that you should note them, in order to remember):

 Connecting to phpMyAdmin
Figure 20 - Connecting to phpMyAdmin

Entering into phpMyAdmin account
Figure 21 - Entering into phpMyAdmin account

Notice that a database with the name of the cloud application was created simultaneously, secondExample.

These are the main steps in creating a cloud application, which is based on databases; from now on you can expand the cloud application as you like, by adding any cartridges you need, populating the database and so on.


Tags: PHP, cloud development

Originally published on http://www.developer.com.

Page 3 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel