A script to easily install PHP extensions in official PHP Docker images, handling dependencies and cleanup.
mlocati/docker-php-extension-installer is a script that simplifies the installation of PHP extensions within official PHP Docker images. It automatically manages system dependencies, compiles extensions, and cleans up unnecessary packages to keep Docker images small. It supports over 150 PHP extensions across multiple PHP versions and works with both Debian-based and Alpine-based Docker images.
Developers building PHP applications in containerized environments using official PHP Docker images, particularly those who need to install additional PHP extensions efficiently while maintaining small image sizes.
Developers choose this tool because it provides a zero-configuration, reliable way to install PHP extensions with automatic dependency management and cleanup, following Docker best practices to ensure lean and production-ready images. Its broad extension support and flexible installation methods (from PECL, GitHub, or local source) make it a comprehensive solution compared to manual installation.
Easily install PHP extensions in Docker containers
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Installs required APT/APK packages and removes them post-installation, minimizing Docker image size as highlighted in the description.
Supports over 150 PHP extensions across versions 5.5 to 8.5, including popular ones like GD and xdebug, detailed in the extensions table.
Allows installation from PECL, specific versions, GitHub repos, or local source code, with syntax for version pinning and pre-releases as shown in examples.
Works with Debian-based (from Jessie) and Alpine-based (from Alpine 3.9) Docker images, ensuring wide applicability across common distributions.
Some extensions like cassandra or parallel have special requirements, such as distribution incompatibilities or needing ZTS images, complicating usage in certain setups.
When copying the script from Docker images, there's a warning about potential outdated versions unless manually updated, introducing maintenance overhead.
Relies on downloading from GitHub, PECL, or other online repositories, which can be a bottleneck in offline or air-gapped environments.