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.
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.
App Platform looks for any of the following to detect a PHP application:
composer.json
index.php
App Platform uses version 254
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.9
).
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:
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"
}
}
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": {
"github.com": "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.com": "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:
App Platform does not enable PHP extensions by default, but you can enable them by requiring them in your app’s composer.json
file.
For example, to enable the GD extension, add the ext-gd
field to your composer.json
file:
{
"require": {
"ext-gd": "*"
}
}
The asterisk (*
) indicates that your application can use any version of the GD extension.
Once you’ve updated the composer.json
file, update your app’s dependencies:
composer update
Once you’ve updated your app’s dependencies, push the changes to your app’s repository. This triggers the app to redeploy with the new extensions.
For a list of available extensions, see Heroku’s documentation.
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.