Build a PHP MySQL application and database

5 min read

Build a PHP MySQL application and database

Alright, you asked for it! You got it. A very simple PHP MySQL application that talks to a database. No bells and whistles. It’s perfect for a new developer. With the click of the button below, you are up and running a PHP application:


The source is located here:

What does the Deploy button do?

When you click the Deploy To Bluemix button, two things will happen:

  • You will get your own copy of the application.

  • A MySQL service will get created for you if do not already have one.

After the deployment finishes (in under a minute), you will get a URL to access your application. Because you have an empty database, the first thing you need to do is create the database table: Click on the Create the Table link. This will redirect you to init.php, which will create a new table.

You’re now ready to to start inserting data into the database. Simply type anything you want into the text box and click Enter.


How does the sample PHP MySQL work?

Three PHP files make up this app:

  • db.php: Reads the mysql database credentials from the VCAP_SERVICES environment variable when running in Bluemix. If you want to run this application locally with a local mysql database, this is where you enter your credentials.

  • init.php: Creates the database table. It will also first drop the table if one already exists.

  • index.php: The main UI of the application.

Modifying the code using DevOps Services (in your browser)

Click on your application in the Bluemix Dashboard, and then click Edit Code. Make your changes and click Deploy!

Modifying the code locally

Download the code from Make changes to the code using your favorite editor:

  • Modify the manifest.yml file and update the name field with your Bluemix application name.

  • cf push from the root of the application source.

What next?

Use one of the many services offered in the Bluemix Catalog to make this application better! For example, use the Watson Personality Insights service to perform linguistic analytics to extract a spectrum of cognitive and social characteristics from the text you enter. The possibilities are endless.



Be the first to hear about news, product updates, and innovation from IBM Cloud