CloudFoundry PHP Example Application: PHPPgAdmin
This is an example application which can be run on CloudFoundry using the PHP Buildpack.
This is an out-of-the-box implementation of PHPPgAdmin. It's an example how common PHP applications can easily be run on CloudFoundry.
- Clone the app (i.e. this repo).
git clone https://github.com/cloudfoundry-samples/cf-ex-phppgadmin cd cf-ex-phppgadmin
- If you don't have one already, create a Postgres service. With Pivotal Web Services, the following command will create a free Postgres database through ElephantSQL.
cf create-service elephantsql turtle pgsql
- Push it to CloudFoundry.
Access your application URL in the browser. Login with the credentials for your service. If you need to find these, just run this command and look for the VCAP_SERVICES environment variable under the
System Provided section.
cf env <app-name>
How It Works
When you push the application here's what happens.
- The local bits are pushed to your target. This is small, less than 10 files around 30k. It includes the changes we made and a build pack extension for PHPPgAdmin.
- The server downloads the [PHP Build Pack] and runs it. This installs HTTPD and PHP.
- The build pack sees the extension that we pushed and runs it. The extension downloads the stock PHPPgAdmin file from their server, unzips it and installs it into the
htdocsdirectory. It then copies the rest of the files that we pushed and replaces the default PHPPgAdmin files with them. In this case, it's just the
- At this point, the build pack is done and CF runs our droplet.
These changes were made to prepare it to run on CloudFoundry:
- Configure the database in
config.inc.php. This was done by reading the environment variable VCAP_SERVICES, which is populated by CloudFoundry and contains the connection information for our services, and configuring the host, port from it. See this link for the details.