Convert Figma logo to code with AI

mlocati logodocker-php-extension-installer

Easily install PHP extensions in Docker containers

4,203
380
4,203
9

Top Related Projects

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

12,358

Full PHP development environment for Docker.

๐Ÿณ Production-ready Docker images for PHP. Optimized for Laravel, WordPress, and more!

Quick Overview

The mlocati/docker-php-extension-installer is a GitHub repository that provides a script for easily installing PHP extensions in Docker containers. It simplifies the process of adding PHP extensions to Docker images, making it particularly useful for developers working with PHP in containerized environments.

Pros

  • Simplifies the installation of PHP extensions in Docker containers
  • Supports a wide range of PHP extensions
  • Regularly updated to include new PHP versions and extensions
  • Can be easily integrated into Dockerfiles

Cons

  • Limited to PHP extensions only, not suitable for other language extensions
  • May require additional configuration for some complex extensions
  • Depends on external package repositories, which could potentially introduce security risks
  • Performance impact when installing multiple extensions in a single Docker image

Getting Started

To use the docker-php-extension-installer in your Dockerfile, add the following lines:

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions gd xdebug redis

This example downloads the latest version of the script, makes it executable, and installs the GD, Xdebug, and Redis extensions. You can replace these with any supported PHP extensions you need for your project.

Competitor Comparisons

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

Pros of setup-php

  • Broader scope: Supports multiple operating systems (Ubuntu, macOS, Windows)
  • GitHub Actions integration: Designed specifically for CI/CD workflows
  • Extensive PHP tooling support: Includes Composer, PECL, and various PHP tools

Cons of setup-php

  • Complexity: May be overkill for simple Docker-based PHP setups
  • Learning curve: Requires understanding of GitHub Actions and workflow syntax

Code Comparison

setup-php (GitHub Actions workflow):

steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
  with:
    php-version: '7.4'
    extensions: mbstring, xml
    coverage: xdebug

docker-php-extension-installer (Dockerfile):

FROM php:7.4-fpm
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions mbstring xml

Both projects aim to simplify PHP extension installation, but setup-php is more comprehensive and tailored for GitHub Actions, while docker-php-extension-installer is focused on Docker environments. setup-php offers broader platform support and additional PHP tooling, but may be more complex for simple use cases. docker-php-extension-installer provides a straightforward solution for Docker-based PHP projects with minimal overhead.

12,358

Full PHP development environment for Docker.

Pros of Laradock

  • Comprehensive development environment with multiple services (PHP, MySQL, Redis, etc.)
  • Pre-configured for Laravel projects, reducing setup time
  • Active community and frequent updates

Cons of Laradock

  • Larger footprint and potentially slower startup times
  • May include unnecessary services for simpler projects
  • Steeper learning curve for Docker beginners

Code Comparison

docker-php-extension-installer:

FROM php:7.4-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions gd xdebug

Laradock:

version: '3'
services:
  php-fpm:
    build:
      context: ./php-fpm
      args:
        - INSTALL_XDEBUG=true
        - INSTALL_GD=true

docker-php-extension-installer focuses solely on installing PHP extensions, making it lightweight and easy to use. It's ideal for projects that require specific PHP extensions without the need for a full development environment.

Laradock, on the other hand, provides a complete development environment with multiple services. It's better suited for complex projects, especially those using Laravel, but may be overkill for simpler applications.

๐Ÿณ Production-ready Docker images for PHP. Optimized for Laravel, WordPress, and more!

Pros of docker-php

  • Provides a more comprehensive PHP development environment with additional tools and configurations
  • Offers pre-built images for various PHP versions and configurations
  • Includes support for multiple web servers (Apache, Nginx) out of the box

Cons of docker-php

  • May have a larger image size due to additional included tools and configurations
  • Potentially more complex setup for users who only need basic PHP functionality
  • Less focused on extension installation, which is the primary purpose of docker-php-extension-installer

Code Comparison

docker-php-extension-installer:

FROM php:7.4-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions gd xdebug

docker-php:

FROM serversideup/php:8.2-fpm-nginx
RUN apt-get update && apt-get install -y \
    libpng-dev \
    && docker-php-ext-install gd

The docker-php-extension-installer focuses on simplifying extension installation, while docker-php provides a more complete development environment with pre-configured web servers and additional tools. Users should choose based on their specific needs and preferences for simplicity versus comprehensiveness.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Downloaded GitHub Releases Docker Hub pulls Test recent

Easy installation of PHP extensions in official PHP Docker images

This repository contains a script that can be used to easily install a PHP extension inside the official PHP Docker images.

The script will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed so that the image will be much smaller.

Supported docker images are:

  • Debian-based docker images: since jessie (Debian 8) (minimum PHP version: 5.5)
  • Alpine-based docker images: since Alpine 3.9 (minimum PHP version: 7.1)

See also the notes in the Special requirements section.

Usage

You have many ways to use this script within your Dockerfiles.

Here's a list of sample Dockerfiles that install the GD and xdebug PHP extensions:

Downloading the script on the fly with ADD

FROM php:7.2-cli

ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN install-php-extensions gd xdebug

Downloading the script on the fly with curl

FROM php:7.2-cli

RUN curl -sSLf \
        -o /usr/local/bin/install-php-extensions \
        https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
    chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions gd xdebug

Direct execution with curl

FROM php:8.2-cli

RUN ( curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - || echo 'return 1' ) | sh -s \
      gd xdebug

Copying the script from a Docker image

FROM php:7.2-cli

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN install-php-extensions gd xdebug

Warning: by using this method you may use an outdated version of the mlocati/php-extension-installer image. You may want to run docker pull mlocati/php-extension-installer in order to use an up-to-date version.

Using the script of a Docker image

RUN  --mount=type=bind,from=mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \
      install-php-extensions gd xdebug

Warning: by using this method you may use an outdated version of the mlocati/php-extension-installer image. You may want to run docker pull mlocati/php-extension-installer in order to use an up-to-date version.

Installing specific versions of an extension

Simply append -<version> to the module name. For example:

install-php-extensions xdebug-2.9.7

The script also supports resolving compatible versions by prefixing the version with a caret (^). For example:

# Install the most recent xdebug 2.x version (for example 2.9.8)
install-php-extensions xdebug-^2
# Install the most recent xdebug 2.8.x version (for example 2.8.1)
install-php-extensions xdebug-^2.8

Please remark that with the syntax above you'll get the vary latest compatible version, which may be unstable. In order to install the most recent stable version, you can append @stable:

# Install the most recent STABLE xdebug 3.x version (for example 3.2.2)
install-php-extensions xdebug-^3@stable

(valid suffixes are: @snapshot, @devel, @alpha, @beta, and @stable)

Pre-release versions extensions available on PECL can be setup by suffixing the extension's name with its state i.e. alpha, beta, rc, preview, devel or snapshot. For example:

install-php-extensions xdebug-beta

TIP: When the latest version available on PECL is not stable, and you want to keep the last stable version, force it by suffixing the extension's name with the stable state. For example:

install-php-extensions mongodb-stable

Installing an extension from its source code

You can also install PHP extensions from source code (provided that it comes with a package.xml or a package2.xml file).

Accepted formats are:

  • A short version for repositories hosted on GitHub.
    For example, for the php-memcached-dev/php-memcached GitHub repository, you can simply write:
    # Install from a specific commit (full commit SHA-1)
    install-php-extensions php-memcached-dev/php-memcached@8f106564e6bb005ca6100b12ccc89000daafa9d8
    # Install from a specific commit (short commit SHA-1)
    install-php-extensions php-memcached-dev/php-memcached@8f106564e6bb
    # Install from tag v3.2.0RC2
    install-php-extensions php-memcached-dev/php-memcached@v3.2.0RC2
    install-php-extensions php-memcached-dev/php-memcached@refs/tags/v3.2.0RC2
    # Install from branch master
    install-php-extensions php-memcached-dev/php-memcached@master
    install-php-extensions php-memcached-dev/php-memcached@refs/heads/master
    
  • An URL providing an archive containing the source code.
    Examples:
    # tgz archive for commit 8f106564e6bb005ca6100b12ccc89000daafa9d8
    install-php-extensions https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/8f106564e6bb005ca6100b12ccc89000daafa9d8
    # tgz archive for tag v3.1.5
    install-php-extensions https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/refs/tags/v3.1.5
    # tgz archive for branch master
    install-php-extensions https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/refs/heads/master
    
  • The absolute path of a local directory.
    Examples:
    # Download the source code
    curl -o /tmp/source.tgz https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/refs/tags/v3.1.5
    tar xzf /tmp/source.tgz -C /tmp
    install-php-extensions /tmp/php-memcached-3.1.5
    

Installing composer

You can also install composer, and you also can specify a major version of it, or a full version.

Examples:

# Install the latest version
install-php-extensions @composer
# Install the latest 1.x version
install-php-extensions @composer-1
# Install a specific version
install-php-extensions @composer-2.0.2

Issue with Let's Encrypt certificates

The root CA certificate of Let's Encrypt changes (more details here).
That breaks old linux distributions, namely:

  • Debian Jessie (8)
  • Debian Stretch (9)
  • Alpine Linux 3.7
  • Alpine Linux 3.8

This script can fix this issue: simply pass @fix_letsencrypt as an argument:

install-php-extensions @fix_letsencrypt

Supported PHP extensions

ExtensionPHP 8.4PHP 8.3PHP 8.2PHP 8.1PHP 8.0PHP 7.4PHP 7.3PHP 7.2PHP 7.1PHP 7.0PHP 5.6PHP 5.5
amqpโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
apcuโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
apcu_bcโœ“โœ“โœ“โœ“โœ“
astโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
bcmathโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
bitsetโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
blackfireโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
bz2โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
calendarโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
cassandra*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
cmarkโœ“โœ“โœ“โœ“โœ“
csvโœ“โœ“โœ“โœ“โœ“โœ“โœ“
dbaโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
ddtrace*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
decimalโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
dsโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
ecma_intl*โœ“โœ“
enchantโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
evโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
eventโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
excimerโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
exifโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
ffiโœ“โœ“โœ“โœ“โœ“โœ“
ftpโœ“โœ“โœ“
gdโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
gearmanโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
geoipโœ“โœ“โœ“โœ“โœ“โœ“โœ“
geos*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
geospatialโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
gettextโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
gmagickโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
gmpโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
gnupgโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
grpcโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
httpโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
igbinaryโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
imagickโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
imapโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
inotifyโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
interbaseโœ“โœ“โœ“โœ“โœ“โœ“
intlโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
ionโœ“โœ“โœ“โœ“
ioncube_loaderโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
jsminโœ“โœ“โœ“โœ“โœ“โœ“โœ“
json_postโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
jsonpathโœ“โœ“โœ“โœ“โœ“โœ“
ldapโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
luasandboxโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
lz4*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
lzfโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
mailparseโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
maxminddbโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
mcryptโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
memcacheโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
memcachedโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
memprof*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
mongoโœ“โœ“
mongodbโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
mosquittoโœ“โœ“โœ“โœ“โœ“โœ“โœ“
msgpackโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
mssqlโœ“โœ“
mysqlโœ“โœ“
mysqliโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
newrelicโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
oauthโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
oci8โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
odbcโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
opcacheโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
opencensusโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
openswooleโœ“โœ“โœ“โœ“โœ“โœ“โœ“
opentelemetryโœ“โœ“โœ“โœ“โœ“
parallel*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
parle*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pcntlโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pcovโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_dblibโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_firebirdโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_mysqlโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_ociโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_odbcโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_pgsqlโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pdo_sqlsrvโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pgsqlโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
php_trieโœ“โœ“โœ“โœ“โœ“โœ“โœ“
phpy*โœ“โœ“โœ“โœ“
pkcs11โœ“โœ“โœ“โœ“โœ“โœ“
pqโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
proproโœ“โœ“โœ“โœ“โœ“โœ“โœ“
protobufโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pspellโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
pthreads*โœ“โœ“โœ“
raphfโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
rdkafkaโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
recodeโœ“โœ“โœ“โœ“โœ“โœ“
redisโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
relayโœ“โœ“โœ“โœ“โœ“
saxon*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
seasclickโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
seaslogโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
shmopโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
simdjson*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
smbclientโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
snappyโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
snmpโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
snuffleupagusโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
soapโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
socketsโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sodium*โœ“โœ“โœ“
solrโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sourceguardianโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
spxโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sqlsrv*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
ssh2โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
stompโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
swooleโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sybase_ctโœ“โœ“
syncโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sysvmsgโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sysvsemโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
sysvshmโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
tensorโœ“โœ“โœ“โœ“โœ“โœ“
tidewaysโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
tidyโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
timezonedbโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
uopzโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
uploadprogressโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
uuidโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
uvโœ“โœ“โœ“โœ“โœ“
vips*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
vldโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
wddxโœ“โœ“โœ“โœ“โœ“โœ“
wikidiff2*โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xdebugโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xdiffโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xhprofโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xlswriterโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xmldiffโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xmlrpcโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
xpass*โœ“โœ“โœ“โœ“โœ“
xslโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
yacโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
yamlโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
yarโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
zephir_parserโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
zipโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
zmqโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
zookeeperโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“
zstdโœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“โœ“

Number of supported extensions: 148

PS: the pre-installed PHP extensions are excluded from this list. You can list them with the following command (change php:7.2-cli to reflect the PHP version you are interested in):

$ docker run --rm php:7.2-cli php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

Configuration

You can configure the behavior of the script, as well as fine-tune some extensions in order fit your needs, by using environment variables.

Here's an example:

IPE_LZF_BETTERCOMPRESSION=1 install-php-extensions lzf

Here's the list of all the supported environment variables:

ExtensionEnvironment variableDescription
IPE_DEBUG=1By setting this environment variable, the script will print all the commands it executes (it will be very verbose, useful only for debug purposes)
IPE_PROCESSOR_COUNTBy default all available processors. Set this environment variable to override the number of processors detected by the script (used for parallel compilation)
IPE_DONT_ENABLE=1By default the script will install and enable the extensions.
If you want to only install them (without enabling them) you can set this environment variable.
To enable the extensions at a later time you can execute the command docker-php-ext-enable-<extension> (for example: docker-php-ext-enable-xdebug).
Beware: installing some PHP extensions requires that other PHP extensions are already enabled, so use this feature wisely.
IPE_SKIP_CHECK=1By default the script will check if the extensions can be enabled: if you want to skip this check, you can use this flag.
Beware: extensions may be enabled even if they break PHP: use this function wisely.
IPE_KEEP_SYSPKG_CACHE=1By default the script will clear the apt/apk/pear cache in order to save disk space. You can disable it by setting this environment variable
lzfIPE_LZF_BETTERCOMPRESSION=1By default install-php-extensions compiles the lzf extension to prefer speed over size; you can use this environment variable to compile it preferring size over speed
eventIPE_EVENT_NAMESPACE=...By default, the event classes are defined in the root namespace. You can use this environment variable to specify a custom namespace
gdIPE_GD_WITHOUTAVIF=1Since PHP 8.1, gd supports the AVIF format. Enabling it requires compiling libaom/libdav1d/libyuv/libavif on Debian 11- and Alpine 3.14-, which is time-consuming. You can disable AVIF support by setting this environment variable on Debian 11- and Alpine 3.14-
oci8 & pdo_ociIPE_INSTANTCLIENT_BASIC=1The oci8 and pdo_oci PHP extensions require Oracle Instant Client. In order to save disk space, we install the Basic Lite version: if you want to install the Basic (non-lite) version simply set this environment variable
http, intl, mongodbIPE_ICU_EN_ONLY=1Some extensions require the ICU library, use this flag to install a smaller, but English-only, ICU library on Alpine 3.16 and later
pspellIPE_ASPELL_LANGUAGES='...'Configure the languages to be made available (for example: IPE_ASPELL_LANGUAGES='en fr'). If omitted, we'll assume en
IPE_DEB_ARCHIVE & IPE_DEB_ARCHIVE_SECURITYThe APT packages of very old Debian versions (eg Jessie) may have been archived: you can use these environment variables to specify custom URLs of these APT archives
newrelicIPE_NEWRELIC_DAEMON=1Install the NewRelic daemon
newrelicIPE_NEWRELIC_KEEPLOG=1Keep the log files of NewRelic setup (/tmp/nrinstall-รขย€ยฆ.tar)
newrelicNR_INSTALL_KEYYour New Relic license key

Special requirements

Some extensions have special requirements:

ExtensionRequirements
cassandraโ€ข Not available in jessie docker images
โ€ข Not available in stretch docker images
โ€ข Not available in buster docker images
โ€ข Not available in bullseye docker images
โ€ข Not available in bookworm docker images
ddtraceNot available in jessie docker images
ecma_intlโ€ข Not available in buster docker images
โ€ข Not available in bullseye docker images
geosโ€ข Not available in alpine3.9 docker images
โ€ข Not available in alpine3.10 docker images
lz4Not available in jessie docker images
memprofโ€ข Not available in alpine3.9 docker images
โ€ข Not available in alpine3.10 docker images
โ€ข Not available in alpine3.11 docker images
โ€ข Not available in alpine3.12 docker images
โ€ข Not available in alpine3.13 docker images
โ€ข Not available in alpine3.14 docker images
โ€ข Not available in alpine3.15 docker images
parallelRequires images with PHP compiled with thread-safety enabled (zts)
parleNot available in jessie docker images
phpyNot available in buster docker images
pthreadsRequires images with PHP compiled with thread-safety enabled (zts)
saxonNot available in alpine docker images
simdjsonโ€ข Not available in jessie docker images
โ€ข Not available in stretch docker images
sodiumNot available in jessie docker images
sqlsrvโ€ข Not available in 7.1-alpine3.9 docker images
โ€ข Not available in 7.1-alpine3.10 docker images
vipsโ€ข Not available in alpine3.9 docker images
โ€ข Not available in jessie docker images
wikidiff2โ€ข Not available in jessie docker images
โ€ข Not available in stretch docker images
xpassNot available in buster docker images

How do I know which Linux distribution I am using?

You can run this command:

cat /etc/os-release

For example:

  • for Debian 11 (Bullseye) you'll see:
    PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
    
  • for Alpine Linux 3.14 you'll see:
    PRETTY_NAME="Alpine Linux v3.14"
    

Tests

When submitting a pull request, a GitHub Action is executed to check if affected PHP extensions actually work (see below).

Furthermore, we also check that new versions of extensions in the PECL repository will still work. This is done on a scheduled basis with another GitHub Action.
In case of failure, a message is sent to a Telegram Channel.
Feel free to subscribe to it to receive failure notifications.

How to contribute

Formatting code

Before submitting any pull request, you should execute the lint script in the scripts directory (or lint.bat on Windows).

If you don't do that, and if there's a coding style error, you'll see that the Check shell coding style and/or the Check PHP coding style GitHub Actions will fail.

The error will be something like this:

--- filename.orig
+++ filename
@@ -line number,7 +line number,7 @@
     good line of code #1
     good line of code #2
     good line of code #3
-    the original line with a wrong coding style
+    the line wrong coding style that has been corrected
     good line of code #4
     good line of code #5
     good line of code #6

So, you should fix highlighted line (the one(s) at line number) by replacing what you see after the - with what you see after the +

Adding support to a new PHP extension?

  1. change the install-php-extensions script
  2. update the data/supported-extensions file, adding a new line with the handle of the extension and the list of supported PHP versions
  3. if the extension requires ZTS images:
    add a new line to the data/special-requirements file, with the extension handle followed by a space and zts

See this pull request for an example.

Changing the supported PHP versions for an already supported PHP extension?

  1. change the install-php-extensions script
  2. update the data/supported-extensions file, adding the new PHP version to the existing line corresponding to the updated extension

See this pull request for an example.

Improving code for an already supported extension?

If you change some code that affects one or more extensions, please add a line with Test: extension1, extension2 to the message of one of the pull request commits. That way, the test jobs will check the extension even if you don't touch the data/supported-extensions file.

Here's an example of a commit message:

Improve the GD and ZIP extensions

Test: gd, zip

Tests only check the installation of a single PHP extension at a time. If you want to test installing more PHP extensions at the same time, use a commit message like this:

Improve the GD and ZIP extensions

Test: gd+zip

If your pull request contains multiple commits, we'll check the "Test:" message of every commit. If you want to stop parsing next commits, add -STOP- in the "Test:" line, for example:

Improve the GD and ZIP extensions

Test: gd, zip, -STOP-

See this pull request for an example.

PHP requirements and configure options

PHP extensions published on the PECL archive contain a package.xml (or package2.xml) file describing the supported PHP versions and the options that can be used to compile it. When we add support for a new PHP extension, and when a new version of a PHP extension is released, we have to check those constraints.

It's a rather tedious task, so I developed a project that lets you easily check those constraints: you can find it at https://mlocati.github.io/pecl-info (here you can find its source code).

For the maintainers

See the MAINTAINERS.md file.

Do you want to really say thank you?

You can offer me a monthly coffee or a one-time coffee :wink: