Senthil Vaiyapuri
posted this on August 24, 2011 15:29
PHP applications are supported through Apache and mod_php.
Assuming your vcap target supports PHP, you can get started quickly with wordpress like this:
git clone git://github.com/phpfog/af-sample-wordpress.git
cd af-sample-wordpress
vmc push wp --url wp.vcap.me –n
vmc create-service mysql --bind wp
Cloud Foundry makes the service connection credentials available as JSON via the VCAP_SERVICES environment variable. Using this knowledge, you can use the following snippet in your own PHP code:
$services = getenv("VCAP_SERVICES");
$services_json = json_decode($services,true);
$mysql_config = $services_json["mysql- 5.1"][0]["credentials"];
define('DB_NAME', $mysql_config["name"]);
define('DB_USER', $mysql_config["user"]);
define('DB_PASSWORD', $mysql_config["password"]);
define('DB_HOST', $mysql_config["hostname"]);
define('DB_PORT', $mysql_config["port"]);
To discover and use PHP support, you need the pre-release version of VMC client gem installed or you can use the AppFog client gem af.
gem install vmc --pre
This should install version 0.3.13.beta.2 or higher.
of AppFog client gem 'af'
gem install af
1. WordPress PHP App : https://github.com/phpfog/af-sample-wordpress