PHP Cloud Native Buildpack

Page last updated:

This topic describes using the PHP Cloud Native Buildpack (CNB) to deploy your apps.

Supported Software and Versions

The release notes page has a list of currently supported PHP versions and extensions.

  • PHP Versions: The two most recent maintenance versions of every actively supported PHP minor release are available. For information about supported releases, see the PHP documentation.

  • PHP Extensions: Many of the most popular PHP extensions are included as shared libraries so that these extensions are ready for use in your apps.

Push an App

30 Second Tutorial

Getting started with this Cloud Native Buildpack is easy. With the Cloud Foundry Command Line Interface installed, open a shell, change directories to the root of your PHP files and push your application.


$ mkdir my-php-app
$ cd my-php-app
$ mkdir htdocs
$ cat << EOF > htdocs/index.php
$ cf push -m 128M my-php-app

Change my-php-app in the above example to a unique name on your target Cloud Foundry instance to prevent a hostname conflict error and failed push.

The example above creates and pushes a test application, my-php-app, to Cloud Foundry. It sets the memory limit to 128M which is plenty for a small PHP app. For questions on those consult the output of cf help push.

Here’s a breakdown of what happens when you run the example above.

  • On your PC:
    • It will create a project folder, a folder for your public files and one PHP file, which just invokes phpinfo()
    • Run cf to push your application. This will create a new application with a memory limit of 128M (more than enough here) and upload our test file.
  • Within Cloud Foundry:
    • The buildpack is executed.
    • PHP is downloaded, configured with the buildpack defaults and run.
    • Your application is accessible at the URL (Replacing with the domain of your public CF provider or private instance).

More information about deploying

While the 30 Second Tutorial shows how quick and easy it is to get started using the buildpack, it skips over quite a bit of what you can do to adjust, configure and extend the buildpack. The following sections and links provide a more in-depth look at the buildpack.


Here are some special features of the buildpack.

  • Full support for deploying PHP apps that use Composer
  • Supports three different HTTP server options: PHP built-in web server, Apache HTTP Server and Nginx
  • Automatic configuration of PHP-FPM, when using external web servers
  • Smart session storage, defaults to file w/sticky sessions but can also use Redis or Memcached for storage.
  • Automatically updated PHP binaries, compiled with a large set of PHP extensions.


Here are some example applications that can be used with this buildpack.

  • php-info This app has a basic index page and shows the output of phpinfo().
  • PHPMyAdmin A deployment of PHPMyAdmin that uses bound MySQL services.
  • PHPPgAdmin A deployment of PHPPgAdmin that uses bound PostgreSQL services.
  • Drupal A deployment of Drupal that uses bound MySQL service.
  • CodeIgniter CodeIgniter tutorial application running on CF.
  • Stand Alone An example which runs a standalone PHP script.
  • pgbouncer An example which runs the PgBouncer process in the container to pool database connections.
  • phalcon An example which runs a Phalcon based application.
  • composer An example which uses Composer.

There are also a set of acceptance tests which are run against the PHP CNB, which you can review for more examples. See buildpack-acceptance-tests in GitHub.

Advanced Topics

See the following topics:

You can find the source for the Cloud Native Buildpack on GitHub:

Proxy Support

If you need to use a proxy to download dependencies during staging, you can set the http_proxy and/or https_proxy environment variables. For more information, see the Using a Proxy Server.

BOSH Configured Custom Trusted Certificate Support

For versions of PHP 5.6.0 and later, the default certificate location is /usr/lib/ssl/certs, which symlinks to /etc/ssl/certs. Your platform operator can configure the platform to add the custom certificates into the application container.

Help and Support

Join the #buildpacks channel in our Slack community if you need any further assistance.

For more information about using and extending the PHP Cloud Native Buildpack in Cloud Foundry, see the php-cnb GitHub repository.

You can find current information about this buildpack on the PHP buildpack release page in GitHub.


The Cloud Foundry PHP Cloud-Native Buildpack is released under version 2.0 of the Apache License.

Create a pull request or raise an issue on the source for this page in GitHub