DDEV users periodically ask if they can use a specific PHP patch version with their projects, either to test/compare for a particular bug or to match a production version exactly.
This experimental add-on tries to address that need, although there are a number of caveats:
- The build done using this process uses the technique from static-php-cli and full details are available there. It supports all the versions supported in the upstream repository, currently PHP 7.3-8.5.
- The build does not match the build done using the official DDEV php packages (which actually come from deb.sury.org.
- It currently does not provide xdebug, see extension support.
- The resultant PHP binaries built here do not have the exact same extensions as the official DDEV PHP binaries.
- Building the binaries happens in the build phase of
ddev start, and it takes a long time on the firstddev startor whenever you change versions. My tests on Gitpod, with a great internet connection, took about 8-9 minutes. It can be really annoying, and a better way to build would be an improvement. - If you want to see the build process as it proceeds, you can use
ddev utility rebuildorDDEV_VERBOSE=true ddev start. - When you use this add-on, your DDEV
php_versionsetting is ignored. - To see what's going on during the build, use
ddev utility rebuild -s web --cache - Your mileage may vary.
- The static-php-cli repository provides a relatively easy way to build static PHP binaries (the CLI and
php-fpm) which can be used to replace the ones installed inddev-webserver. - The provided
.ddev/web-build/Dockerfile.php-patch-builddoes the building.
# Set your desired PHP version, when prompted, e.g., 8.0.10
ddev add-on get rfay/ddev-php-patch-build
ddev restartAfter installation, make sure to commit the .ddev directory to version control.
You can choose a different PHP version with:
ddev dotenv set .ddev/.env.php-patch-build --static-php-version=8.0.10
ddev add-on get rfay/ddev-php-patch-build
ddev restartAfter installation, make sure to commit the .ddev directory to version control.
If you hit GitHub rate limits while downloading static-php-cli extensions, export your token before running ddev start to build the PHP binaries:
export GITHUB_TOKEN=your_github_token| Variable | Flag | Default |
|---|---|---|
STATIC_PHP_EXTENSIONS |
--static-php-extensions |
apcu,bcmath,ctype,curl,dom,fileinfo,filter,ftp,gd,mbstring,openssl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,phar,session,simplexml,sqlite3,tokenizer,xml |
STATIC_PHP_VERSION |
--static-php-version |
required, (not set) |
Contributed and maintained by @rfay