Building a PHP application

Specify the PHP version

By default the PHP Runtime buildpack uses the latest stable version of PHP. If your application requires a specific version, you can specify one by including a composer.json file in your application's root directory. For example:

"require": {
  "php": "^8.2",
}

Configure Composer

By default, the Composer version is 2.1.3. If you require a specific version of Composer, you can use the GOOGLE_COMPOSER_VERSION environment variable to specify any supported version of Composer using the full semantic version. For example:

pack build sample-php --builder=gcr.io/buildpacks/builder \
  --env GOOGLE_COMPOSER_VERSION="2.2.20"

Customizing NGINX configurations

To configure NGINX, you can use the GOOGLE_CUSTOM_NGINX_CONFIG environment variable to specify your custom NGINX configuration file. For example:

pack build sample-php --builder=gcr.io/buildpacks/builder \
  --env GOOGLE_CUSTOM_NGINX_CONFIG="nginx-custom.conf"

When NGINX starts, your custom NGINX file is used.