Who this is for: people who want to add PHP extensions to a Docker image of their own project (developers and DevOps). Everything you need to use the installer is on this page. If you maintain the installer, read the project documentation in its repository instead.
A PHP extension is an add-on that gives PHP a new ability, such as talking to a Redis server or resizing images. Most extensions have to be compiled (turned from source code into a file PHP can load) and need the right system libraries around them.
install-php-extensions is one command that does all of that. You name the extensions you want, it installs each one and checks that PHP can load it. This image carries the command, its catalog of tested extensions and PIE (the PHP Foundation's official extension installer). It works on the official php images and on the wiediiregistry/php images, on Debian and on Alpine. Every tag works on Intel/AMD (linux/amd64) and on Apple Silicon or ARM servers (linux/arm64).
What it gives you:
pecl. pecl is PHP's old extension tool. It is deprecated and its outages broke builds, so this command never uses it.The image is FROM scratch: it has no shell and nothing to run on its own. You lend it to one RUN step of your Dockerfile with a bind mount (a way to use files from another image without copying them into yours), so nothing from it stays in your final image:
FROM wiediiregistry/php:8.5.12-laravel-debian
USER root
RUN --mount=type=bind,from=wiediiregistry/php-extension-installer:X.Y.Z@sha256:<digest>,source=/usr,target=/opt/wiedii-ext \
sh /opt/wiedii-ext/bin/install-php-extensions exif pcov
USER app
The same line works on the official php images (php:8.5-fpm, php:8.5-cli-alpine). Only the FROM line changes. The command must run as root, so switch to root before the RUN and back to your normal user after it.
Replace X.Y.Z with a release from the Tags tab of this page ("Tags and versions" below explains which one to pick). A digest is the SHA256 fingerprint of an image's exact content. Pinning it means you get exactly the same bytes tomorrow. Replace <digest> with the output of this command: copy the first Digest: line, the one at the top.
docker buildx imagetools inspect wiediiregistry/php-extension-installer:X.Y.Z
The output also lists linux/amd64 and linux/arm64. If it shows only one, or answers not found, the tag is not complete or does not exist; pick another from the Tags tab of this page.
Releases are named X.Y.Z, three numbers such as 1.4.2. Three tags exist for each release:
| Tag | What it means |
|---|---|
X.Y.Z | One exact release. It never changes once published. |
X.Y | The newest release of that minor line. It moves. |
X | The newest release of that major line. It moves. |
Pin the full X.Y.Z together with the digest, and let Renovate (a bot that proposes dependency updates) offer the next release. A change of the first number means something can break: the command line, the image layout or the catalog format changed, so read the release notes before you accept it.
Put options before the extension names.
| Option | What it does |
|---|---|
--list | Shows the catalog: every extension the command knows and the method it uses. Needs no root. |
--dry-run | Shows what would be installed and changes nothing. Needs no root. |
--no-source-fallback | Fails instead of building from the pinned source when PIE fails. |
--version | Prints the installer version. |
--help | Prints the usage text. |
A name such as redis-6.3.0 asks for one specific version (see below for what that means).
To see the catalog from your own machine, build this one-line project with docker build --progress=plain --no-cache .; the list appears in the output:
FROM php:8.5-cli
RUN --mount=type=bind,from=wiediiregistry/php-extension-installer:X.Y.Z@sha256:<digest>,source=/usr,target=/opt/wiedii-ext \
sh /opt/wiedii-ext/bin/install-php-extensions --list
For each extension you ask for, the command tries these sources in order and stops at the first one that works:
gd or bcmath."Pinned" means the exact version and commit are fixed and checked. At the end every extension you requested must load, or the command stops with an error.
If you ask for a name that is not in the catalog, the command does not give up. It looks the name up on Packagist, the official index of PIE packages, and installs the latest stable release it finds. The same happens when you ask for a specific version of any extension, such as redis-6.3.0: that version comes from Packagist and is not checked against our pin. Some extensions cannot take a version: a built-in PHP extension such as gd has no version of its own, and an extension built only from its pinned source has no other version to fetch. For those, install-php-extensions gd-1.2.3 stops with an error that says so; ask for the plain name instead.
This is a deliberate exception to the rule that everything is pinned, approved by the tech lead.
| Image | Limit |
|---|---|
Official php images, standard wiediiregistry/php images | None beyond what the catalog says for each extension. |
bare-* variants of wiediiregistry/php (built on Docker Hardened Images, minimal base images) | No extensions that PHP builds from its own source (gd, zip, bcmath and others): these images carry no PHP source, and the command never downloads it. Use a standard image. |
bare-* on Debian | No extension that needs system libraries. Use bare Alpine or a standard image. |
bare-* production images | They have no shell, so you cannot run the installer inside them. Build the extension in the matching -dev image and copy only its .so file (the compiled extension) and its .ini file (the setting that turns it on). |
-dev images | They already contain the command in /usr/local/bin. Standard -dev images also let you try sudo install-php-extensions <name> in a running container; it is lost on rebuild, so add it to the Dockerfile to keep it. The bare-* -dev images have no sudo. |
PIE downloads from GitHub, which limits anonymous requests. If a build hits the limit, give it a GitHub token as a BuildKit secret (a value that exists only while one build step runs). Never pass it as a build argument: arguments stay readable in the image history. Add --mount=type=secret,id=composer_auth to the RUN line above, put the token in a file, and pass the file to the build:
echo '{"github-oauth": {"github.com": "<token>"}}' > auth.json
docker build --secret id=composer_auth,src=auth.json .
Replace <token> with a GitHub token you created, and never commit auth.json. The command also reads COMPOSER_AUTH from the environment. This image holds no token of its own.
| Symptom | Cause and fix |
|---|---|
attempt N failed, retrying, then a build from source | PIE could not reach GitHub or Packagist (rate limit or outage). Pass a token. Catalog extensions still build from their pinned source. |
… is neither in the catalog, in php-src nor on Packagist | The name is unknown. Check the spelling, or --list. |
PIE could not build … no system packages were installed | The extension is not in the catalog and needs system libraries. Ask the maintainers to add a catalog entry. |
not available on bare Debian (DHI) | It needs system libraries. Use bare Alpine or a standard image. |
… is part of php-src, and this image has no PHP source | A PHP-own extension on a bare image. Use a standard image. |
… is not installed by this command: … | The catalog marks it unsupported, everywhere or only on this operating system. The message says what to use instead. |
no match for platform while building | The tag has no image for your CPU type. Check that docker buildx imagetools inspect <image> lists linux/amd64 and linux/arm64. |
install-php-extensions keeps the same name and the same install-php-extensions <ext> … usage as mlocati/docker-php-extension-installer, which installs most extensions with pecl. Most project Dockerfiles only change the mount:
-RUN --mount=type=bind,from=ghcr.io/mlocati/php-extension-installer:2.12.3,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \
- install-php-extensions pgsql
+RUN --mount=type=bind,from=wiediiregistry/php-extension-installer:X.Y.Z@sha256:<digest>,source=/usr,target=/opt/wiedii-ext \
+ sh /opt/wiedii-ext/bin/install-php-extensions pgsql
The project repository has the full guide (including the extension table, one row per extension) and the maintainer documentation, in English and Spanish, in its docs/ folder. It is internal to Wiedii, so this page repeats everything a visitor needs. General references: Docker documentation, PHP manual, PIE, Packagist.
UNLICENSED. Internal Wiedii use only. The catalog data ported from mlocati's installer is MIT-licensed.
Content type
Image
Digest
sha256:e03f134a4…
Size
1.5 MB
Last updated
7 days ago
docker pull wiediiregistry/php-extension-installer:0