cloudfoundry-samples/cf-ex-phppgadmin

Name: cf-ex-phppgadmin

Owner: Cloud Foundry Sample Applications

Description: CloudFoundry PHP example application: phpPgAdmin

Created: 2015-04-07 13:30:09.0

Updated: 2017-09-21 12:44:33.0

Pushed: 2017-09-21 12:44:32.0

Homepage: null

Size: 6

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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

    clone https://github.com/cloudfoundry-samples/cf-ex-phppgadmin
    f-ex-phppgadmin
    
  2. 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.

    reate-service elephantsql turtle pgsql
    
  3. Push it to CloudFoundry.

    ush
    

    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.

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

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.