PHP Buildpack on App Platform

App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.

How App Platform Builds Images

App Platform supports two ways to build an image for your app: Cloud Native Buildpacks and Dockerfiles.

When you give App Platform access to your code, it defaults to using a Dockerfile if one is present in the root of the directory or specified in the app spec. Otherwise, App Platform checks your code to determine what language or framework it uses. If it supports the language or framework, it chooses an appropriate resource type and uses the proper buildpack to build the app and deploy a container.

heroku-buildpack-php is utilized as the buildpack for detecting and building your PHP applications.

PHP Applications using Buildpacks

App Platform looks for any of the following to detect a PHP application:

  • composer.json
  • index.php

Current Buildpack Version and Supported Runtimes

App Platform uses version 249 of the Heroku PHP Buildpack. The buildpack supports PHP runtime versions 7.4.x, 8.0.x, 8.1.x, 8.2.x and 8.3.x. If no version is specified in your app, App Platform defaults to using the latest PHP release (currently it is 8.3.2).

The PHP buildpack versions that are available are v2, v1, and v0. It should be noted that PHP v2 does not support Ubuntu-18. If you’d like to start using PHP v2, we recommend upgrading your buildpack to Ubuntu-22 before upgrading to newer PHP buildpack versions. To see specific runtimes that are available for these versions, please look at our release notes.

The buildpack supports the following PHP runtime versions:

  • Ubuntu-22
    • 8.3.5 - 8.3.0
    • 8.2.18 - 8.2.1
    • 8.1.27 - 8.1.6
  • Ubuntu-18
    • 8.1.18 - 8.1.0
    • 8.0.28 - 8.0.6
    • 8.0.3 - 8.0.0
    • 7.4.33 - 7.4.32
    • 7.4.30 - 7.4.19
    • 7.4.16 - 7.4.2
    • 7.3.33 - 7.3.13
    • 7.2.34 - 7.2.26
    • 7.1.33

Specify a PHP Version

  • PHP versions 7.x and 8.x are supported. PHP 7.x will be used by default, unless a specific version is requested via composer.json by your app or a dependency. To configure the version used for your app, add a php dependency to composer.json like so:
    "require": {
      "php": "^8.0.0"


Composer and Private Repositories

If your Composer configuration requires access to packages in private repositories, use the COMPOSER_AUTH environment variable to configure your authentication details. Composer automatically reads this variable when needed.

The value of the COMPOSER_AUTH variable is the same JSON structure found in Composer’s auth.json file. If you already have this file, you may extract the relevant portions, remove all new lines, and set the COMPOSER_AUTH value to the resulting single line of JSON.

See Authentication for Privately Hosted Packages and Repositories in the Composer docs for more details on the different authentication types available and the JSON needed to configure them.


A commonly used authentication type is github-oauth . The JSON required to configure github-oauth is shown in the Composer documentation as:

    "github-oauth": {
        "": "token"

To use this on App Platform, first flatten the JSON into a single line, then substitute your GitHub personal access token for token:

COMPOSER_AUTH={"github-oauth":{"": "github_pat_11AABJX..."}}

Multiple authentication types and accounts can be set simultaneously in a single COMPOSER_AUTH variable. For more details on how to set and manage environment variables on App Platform, see How to Use Environment Variables:

Use and encrypt environment variables in App Platform.


Composer versions 1.x and 2.x are supported. App Platform will determine the version to use based on the version of Composer that generated the composer.lock file. Generally, you can update your project by running composer update --lock using Composer 2.