Connecting PHP to MySQL on Bluemix

Most of the PHP I write runs on Bluemix – it’s IBM’s self-service cloud, and since I work there, they pay for my accounts. There are a bunch of databases you can use there, mostly open source offerings, and, of course, with PHP I like to use MySQL. Someone asked me for my connection code since it’s a bit tricky to grab the credentials that you need, so here it is.

Bluemix Environment Variables
In Bluemix, you can simply create a MySQL database (look for “compose-for-mysql" in the catalog), create a set of credentials, and then bind it to your app. I should blog a few more of my PHP-on-Bluemix tricks but you can run a selection of PHP versions and it’s also possible to add the extensions that you need. I have found it does have what I need once I figure out how to configure it!

Link: https://dzone.com/articles/connecting-php-to-mysql-on-bluemix?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev