CloudFoundry PHP example application: phpPgAdmin
Switch branches/tags
Nothing to show
Clone or download
dmikusa-pivotal Update config.inc.php
Make the regular expression more flexible.
Latest commit 871511a Sep 21, 2017

README.md

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.

Usage

  1. Clone the app (i.e. this repo).
git clone https://github.com/cloudfoundry-samples/cf-ex-phppgadmin
cd cf-ex-phppgadmin
  1. 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
  1. Push it to CloudFoundry.
cf push

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.

  1. 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.
  2. The server downloads the [PHP Build Pack] and runs it. This installs HTTPD and PHP.
  3. 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 htdocs directory. 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 config.inc.php file.
  4. At this point, the build pack is done and CF runs our droplet.

Changes

These changes were made to prepare it to run on CloudFoundry:

  1. 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.