This project provides install-php-extensions, a script that installs PHP extensions inside official PHP Docker images and removes unneeded packages afterward to keep images smaller.
Overview
Docker PHP Extension Installer distributes a shell script for adding PHP extensions to official PHP Docker images. It installs required APT or APK packages, builds or enables the requested modules, and removes unnecessary packages when finished so layers stay smaller.
Supported bases include Debian images back to jessie and Alpine images from 3.9, with minimum PHP versions noted per lineage. Usage patterns include downloading the script during image build, copying it from companion container images on GitHub Container Registry or Docker Hub, or invoking a published image directly.
The script supports version pins, compatible version resolution with carets, PECL stability suffixes, installing from GitHub or archive sources, Composer version selectors, and environment variables that tune dependent library versions. Automated tests run on pull requests and on a schedule for extension compatibility.
A separate PHP rewrite is noted as in development for use outside official PHP images but is not described as production-ready.
Key features
- One script for many PHP extensions
- Debian and Alpine PHP image support
- PECL and source installs
- Version pins and stable selectors
- Trims build packages after install
- Composer and fix-letsencrypt helpers
Use cases
- Slimmer custom PHP Docker images
- Repeatable extension installs in CI
- Pinning extension versions in builds