Skip to content

vlvanchin/cf-ex-phpmyadmin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloudFoundry PHP Example Application: PHPMyAdmin

This is an example application which can be run on CloudFoundry using the [PHP Build Pack].

This is an out-of-the-box implementation of PHPMyAdmin 4.8.3. 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-phpmyadmin
    cd cf-ex-phpmyadmin
  2. If you don't have one already, create a MySQL service. With Pivotal Web Services, the following command will create a free MySQL database through ClearDb.

    cf create-service cleardb spark mysql

    If you have an existing DB service with some arbitary name, please re-name the service such that it contains the string mysql. The config.inc.php file will automatically configure MySQL services if the plan is ClearDb or Pivotal MySQL, if they are tagged with mysql or if the service name contains the word mysql. If you do not follow this pattern, your MySQL service will require manual configuration.

  3. Edit the manifest.yml file. Insert your service name, if it's not mysql. Also, set the route that you would like to use.

  4. 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, six files around 30k. It includes the changes we made and a build pack extension for PHPMyAdmin.
  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 PHPMyAdmin 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 PHPMyAdmin 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.
  2. Remove the setup directory, which is not needed.
  3. Override the configuration file httpd-directories.conf and prevent access to the libraries directory. See this link for the details.
  4. Set the 'PmaAbsoluteUri' configuration option. This is needed because the application is using the detected host and port, which are internal to CF, to generate in the URLs. The links generated with the internal ip / port do not work and so we configure around that by grabbing the application's URL and port. Note that this would not work if multiple URL's were bound to the application. Link
  5. Increased the timeout of the session by setting 'LoginCookieValidity' and 'session.gc_maxlifetime' to 1800. Link to change #1 and change #2.

About

CloudFoundry PHP example application: phpmyadmin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 79.9%
  • Python 20.1%