This reference documentation offers an in-depth description of the behavior and configuration options of the Paketo PHP Buildpack. For explanations of how to use the buildpack for several common use-cases, see the Paketo PHP Buildpack How To documentation.
The Paketo PHP Buildpack supports several versions of PHP and Composer. For more details on the specific versions supported in a given buildpack version, see the release notes.
The Paketo PHP Buildpack is a composite buildpack designed to build applications written in PHP.
With the PHP CNB, the only option for package management is Composer.
The Composer buildpack will install composer
as the package manager, and if a PHP
application contains a composer.json
(and preferably a composer.lock
file) packages
are installed by running composer install
by the Composer Install
buildpack. Packages installed will be available in a
vendor
directory in the application source directory, and will be cached for
rebuilds.
The buildpacks within the PHP CNB will configure basic configuration for working with FPM, HTTPD, NGINX, or the built-in PHP webserver. Web server choice is set by the user via environment variable (see PHP How To documentation), and user-provided configurations will be considered as outlined below.
The PHP buildpack supports the full software bill of materials (SBOM) in Syft, CycloneDX, SPDX, and Paketo-specific formats.
Apps built with the buildpack that use Composer as a package manager contain SBOM entries that provide a full picture of the packages installed in the final app image. There are also entries for the installed versions of PHP and Composer. Check out the Access the Software Bill of Materials guide for more information about how to retrieve the SBOM for your app image.
The buildpacks in the PHP language family set default configurations, as well as include configurations from user-provided sources. The sections below outline the various configurations the buildpacks provide during the build process, and the various locations that will also be considered as configuration sources.
This section lists the various configuration sources for PHP .ini
files that
are made available to PHP at run-time.
ini
file found from the PHP
Distribution itself, with no modifications. It can be found on the container
inside the PHP Distribution Buildpack layer under /etc/php.ini
./etc/buildpack.ini
. This includes
configurations specific to the buildpack’s install process and app image file
system, such as the path to PHP extensions (extension_dir
), the include
path to the PHP library directory.<APP-ROOT>/.php.ini.d
directory.Check out the PHP_INI_SCAN_DIR documentation section for more information.
Configuration for PHP FPM comes from a few sources, listed here in order of precedence from highest to lowest:
<APP-ROOT>/.php.fpm.d/*.conf
./workspace/.php.fpm.bp/*.conf
files.listen
directive, and other features
to make FPM work well with web servers.$PHPRC/php-fpm.d/www.conf.default
in the container.The PHP NGINX Buildpack sets up two flavours of configuration itself, and allows for a third flavour from users. They are listed here in order of highest precedence, to lowest.
<APP-ROOT>/.nginx.conf.d/*-http.conf
and
<APP-ROOT>/.nginx.conf.d/*-server.conf
The former can be used to include user-specific config in the http
block,
while the latter is used to include user-specific config in the http.server
block
in the nginx.conf
generated by the buildpack.nginx.conf
file for
running with PHP apps. See PHP How To documentation for settings that can be configured via environment
variables.httpd.conf
file for
running with PHP apps. See PHP How To documentation for settings that
can be configured via environment variables.<APP-ROOT>/.httpd.conf.d/*.conf
.The Composer Install Buildpack sets up configuration to be used for running
composer
commands. They are listed here in no specific order.
.ini
file is created for usage during the buildpack build
process only. It will tell Composer where to find extensions when running
composer-install
..ini
file available on the final image under
/workspace/.php.ini.d/composer-extensions.ini
which will be appended onto
the PHP_INI_SCAN_DIR
. It will include any composer.json
specified
extensions that come from running the Composer check-platform-reqs
command.The buildpacks within the Paketo PHP language family set a number of
environment variables during the build
and launch
phases of the app
lifecycle. The sections below describe each environment variable and its impact
on your app.
php-dist
and composer-install
(build
phase only)build
and launch
php-dist
, php-redis-session-handler
, and php-memcached-session-handler
buildpacksbuild
and launch
ini
configuration can be found.php-dist
and composer-install
(build
phase only)build
and launch
php.ini
php-dist
buildpackbuild
and launch
php-dist
buildpackbuild
and launch
php-dist
buildpackbuild
and launch
php-dist
buildpackbuild
and launch
httpd
buildpacklaunch
httpd
buildpacklaunch
composer-install
buildpackbuild
composer.json
filecomposer-install
buildpackbuild
composer-install
buildpackbuild
composer-install
buildpackbuild
--no-interaction
flag to Composer commandsphp-fpm
buildpackbuild
and launch
php-httpd
buildpackbuild
and launch
php-nginx
buildpackbuild
and launch
Name | Required/Optional | Purpose |
---|---|---|
Paketo PHP Dist Buildpack | Required | Installs the PHP distribution, making it available on the $PATH |
Paketo PHP FPM Buildpack | Required | Configures a php-fpm.conf config file for PHP FPM |
Paketo Composer Buildpack | Optional | Installs the Composer tool onto the $PATH |
Paketo Composer Install Buildpack | Optional | Runs composer install |
Paketo HTTPD Buildpack | Optional | Installs Apache HTTPD |
Paketo NGINX Buildpack | Optional | Installs NGINX |
Paketo PHP HTTPD Buildpack | Optional | Configures HTTPD to serve a PHP app |
Paketo PHP NGINX Buildpack | Optional | Configures NGINX to serve a PHP app |
Paketo PHP Builtin Server Buildpack | Optional | Sets a PHP built-in server start command |
Paketo PHP Redis Session Handler Buildpack | Optional | Configures a PHP session handler for a Redis instance |
Paketo PHP Memcached Session Handler Buildpack | Optional | Configures a PHP session handler for a Memcached instance |
Paketo PHP Start Buildpack | Optional | Sets the start command to serve PHP apps with NGINX or HTTPD with FPM |
Paketo Procfile Buildpack | Optional | Sets a user-specified start command |
Paketo Environment Variables Buildpack | Optional | Sets user-specified launch-time environment variables |
Paketo Image Labels Buildpack | Optional | Adds user-specified labels to app image metadata |
Paketo CA Certificates Buildpack | Optional | Installs custom CA certificates |
Last modified: December 6, 2024