Forums/Knowledge Bases/CloudFoundry.org (OSS) Knowledge Base

PHP support in Cloud Foundry

Senthil Vaiyapuri
posted this on August 24, 2011 15:29

PHP Support

PHP applications are supported through Apache and mod_php.

Example WordPress app

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

Accessing the database

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"]);

Limitations

  • Migration workflow, such as that of symfony are not supported.
  • PHP support is only available from appfog.com or in the local vcap setup from cloudfoundry/vcap github repo. It is not available yet in Micro Cloud Foundry and CloudFoundry.com

VMC

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

Sample Applications

1. WordPress PHP App : https://github.com/phpfog/af-sample-wordpress

 

  

 
Topic is closed for comments