2021-01-15 08:21:12 +00:00
[![Downloaded GitHub Releases ](https://img.shields.io/github/downloads/mlocati/docker-php-extension-installer/total?label=Downloaded%20releases )](https://github.com/mlocati/docker-php-extension-installer/releases)
2022-06-10 06:52:01 +00:00
[![Docker Hub pulls ](https://img.shields.io/docker/pulls/mlocati/php-extension-installer )](https://hub.docker.com/r/mlocati/php-extension-installer)
2020-02-21 12:22:59 +00:00
[![Test recent ](https://github.com/mlocati/docker-php-extension-installer/workflows/Test%20recent/badge.svg )](https://github.com/mlocati/docker-php-extension-installer/actions?query=workflow%3A%22Test+recent%22)
2018-04-12 07:25:43 +00:00
2018-04-11 15:39:10 +00:00
# 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 ](https://hub.docker.com/_/php/ ).
2020-01-08 09:09:44 +00:00
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.
2020-03-03 11:07:51 +00:00
Supported docker images are all the Alpine/Debian versions, except for PHP 5.5 where we only support Debian 8 (jessie) (that is, `php:5.5` , `php:5.5-apache` , `php:5.5-cli` , `php:5.5-fpm` , `php:5.5-zts` ).
See also the notes in the [Special requirements ](#special-requirements ) section.
2018-04-11 15:39:10 +00:00
## Usage
2020-01-08 09:09:44 +00:00
You have two ways to use this script within your `Dockerfile` s: you can download the script on the fly, or you can grab it from the [`mlocati/php-extension-installer` Docker Hub image ](https://hub.docker.com/r/mlocati/php-extension-installer ).
With the first method you are sure you'll always get the very latest version of the script, with the second method the process is faster since you'll use a local image.
2018-04-11 15:39:10 +00:00
2021-09-22 06:44:56 +00:00
For example, here some `Dockerfile` s that install the GD and xdebug PHP extensions:
2020-01-08 09:09:44 +00:00
### Downloading the script on the fly
2021-09-22 06:44:56 +00:00
#### With the Dockerfile
2020-01-08 09:09:44 +00:00
```Dockerfile
2018-04-11 15:39:10 +00:00
FROM php:7.2-cli
2020-12-10 14:59:21 +00:00
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
2018-04-11 15:39:10 +00:00
2021-09-22 04:27:25 +00:00
RUN chmod +x /usr/local/bin/install-php-extensions & & \
2018-04-11 15:45:25 +00:00
install-php-extensions gd xdebug
2018-04-11 15:39:10 +00:00
```
2021-09-22 06:44:56 +00:00
#### With curl
2019-10-09 15:11:51 +00:00
2020-01-08 09:09:44 +00:00
```Dockerfile
2019-10-09 15:11:51 +00:00
FROM php:7.2-cli
2021-09-22 06:44:56 +00:00
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
2019-10-09 15:11:51 +00:00
```
2021-09-22 06:44:56 +00:00
### Copying the script from a Docker image
2021-01-10 19:32:31 +00:00
2021-09-22 06:44:56 +00:00
```Dockerfile
FROM php:7.2-cli
2021-01-10 19:32:31 +00:00
2021-09-22 06:44:56 +00:00
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
2021-01-10 19:32:31 +00:00
2021-09-22 06:44:56 +00:00
RUN install-php-extensions gd xdebug
```
2021-01-10 19:32:31 +00:00
2021-09-22 06:44:56 +00:00
> **Warning**: by using this method you may use an outdated version of the `mlocati/php-extension-installer` image.
>
> In order to be sure the `COPY` instruction uses the very latest version, you can run:
>
> ```sh
> docker pull mlocati/php-extension-installer
> ```
2021-01-10 19:32:31 +00:00
2021-01-26 15:58:14 +00:00
### Installing specific versions of an extension
Let users install a specific PHP module version
Test: amqp,apcu,gmagick,http,pecl_http,igbinary,memcache,mailparse,memcached,mongodb,mosquitto,msgpack,oauth,opencensus,parallel,pcov,pdo_sqlsrv,sqlsrv,propro,protobuf,pthreads,raphf,rdkafka,redis,solr,ssh2,uuid,xdebug,uopz,xhprof,yaml
2020-12-02 17:19:24 +00:00
Simply append `-<version>` to the module name.
For example:
```sh
install-php-extensions xdebug-2.9.7
```
2021-08-13 07:17:19 +00:00
The script also supports resolving *compatible* versions by prefixing the version with a caret (`^`).
2021-01-26 15:58:14 +00:00
For example:
```sh
# Install the most recent xdebug 2.x version (for example 2.9.8)
install-php-extensions xdebug-^2
2021-01-26 16:09:14 +00:00
# Install the most recent xdebug 2.8.x version (for example 2.8.1)
2021-01-26 15:58:14 +00:00
install-php-extensions xdebug-^2.8
```
2021-08-13 07:17:19 +00:00
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` .
2021-07-05 15:46:58 +00:00
For example:
```sh
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:
```sh
install-php-extensions mongodb-stable
```
2021-01-26 15:58:14 +00:00
2022-03-25 09:55:08 +00:00
### Installing from 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:
2022-03-25 09:59:35 +00:00
- A short version for repositories hosted on GitHub.
2022-03-25 09:55:08 +00:00
For example, for the [php-memcached-dev/php-memcached ](https://github.com/php-memcached-dev/php-memcached ) GitHub repository,
you can simply write:
```sh
# 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
```
2022-03-25 09:59:35 +00:00
- An URL providing an archive containing the source code.
2022-03-25 09:55:08 +00:00
Examples:
```sh
# 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
```
2022-03-25 09:59:35 +00:00
- The absolute path of a local directory.
2022-03-25 09:55:08 +00:00
Examples:
```sh
# 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
2020-12-16 10:34:30 +00:00
### Installing composer
You can also install [composer ](https://getcomposer.org/ ), and you also can specify a major version of it, or a full version.
Examples:
```sh
# 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
```
2021-10-08 08:24:06 +00:00
### Issue with Let's Encrypt certificates
The root CA certificate of Let's Encrypt changes ([more details here](https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/)).
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:
```sh
install-php-extensions @fix_letsencrypt
```
2018-04-11 15:39:10 +00:00
## Supported PHP extensions
<!-- START OF EXTENSIONS TABLE -->
<!-- ########################################################### -->
<!-- # # -->
<!-- # DO NOT EDIT THIS TABLE: IT IS GENERATED AUTOMATICALLY # -->
<!-- # # -->
<!-- # EDIT THE data/supported - extensions FILE INSTEAD # -->
<!-- # # -->
<!-- ########################################################### -->
2022-06-11 06:26:56 +00:00
| Extension | PHP 5.5 | PHP 5.6 | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | PHP 8.1 | PHP 8.2 |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| amqp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| apcu | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| apcu_bc | | | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| ast | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| bcmath | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| blackfire | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| bz2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| calendar | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| cmark | | | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| csv | | | | | | ✓ | ✓ | ✓ | ✓ | ✓ |
| dba | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 16:27:53 +00:00
| ddtrace[*](#special-requirements-for-ddtrace) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 06:26:56 +00:00
| decimal | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ds | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| enchant | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ev | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| event | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| excimer | | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| exif | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ffi | | | | | | | ✓ | ✓ | ✓ | ✓ |
| gd | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gearman | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | |
| geoip | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| geos[*](#special-requirements-for-geos) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| geospatial | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gettext | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gmagick | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gmp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gnupg | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| grpc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| http | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| igbinary | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| imagick | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| imap | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| inotify | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| interbase | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | | |
| intl | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ion | | | | | | | | | ✓ | ✓ |
| ioncube_loader | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| jsmin | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| json_post | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ldap | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| luasandbox | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| lzf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mailparse | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| maxminddb | | | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mcrypt | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| memcache | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| memcached | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| memprof[*](#special-requirements-for-memprof) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mongo | ✓ | ✓ | | | | | | | | |
| mongodb | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mosquitto | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
| msgpack | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mssql | ✓ | ✓ | | | | | | | | |
| mysql | ✓ | ✓ | | | | | | | | |
| mysqli | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| oauth | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| oci8 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| odbc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| opcache | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| opencensus | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| openswoole | | | | | ✓ | ✓ | ✓ | ✓ | ✓ | |
| parallel[*](#special-requirements-for-parallel) | | | | ✓ | ✓ | ✓ | ✓ | | | |
| parle[*](#special-requirements-for-parle) | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pcntl | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pcov | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 16:46:47 +00:00
| pdo_dblib | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 06:26:56 +00:00
| pdo_firebird | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_mysql | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_oci | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_odbc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_pgsql | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_sqlsrv[*](#special-requirements-for-pdo_sqlsrv) | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pgsql | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| php_trie | | | | | | ✓ | ✓ | ✓ | ✓ | ✓ |
| propro | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | |
2022-06-11 16:46:47 +00:00
| protobuf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 06:26:56 +00:00
| pspell | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pthreads[*](#special-requirements-for-pthreads) | ✓ | ✓ | ✓ | | | | | | | |
2022-06-13 07:32:09 +00:00
| raphf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 06:26:56 +00:00
| rdkafka | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| recode | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | | |
| redis | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| seaslog | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| shmop | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| smbclient | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| snmp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| snuffleupagus | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| soap | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 15:10:38 +00:00
| sockets | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2022-06-11 16:04:15 +00:00
| sodium[*](#special-requirements-for-sodium) | | ✓ | ✓ | ✓ | | | | | | |
2022-06-11 06:26:56 +00:00
| solr | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | |
| sourceguardian | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | |
| spx | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| sqlsrv[*](#special-requirements-for-sqlsrv) | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ssh2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| stomp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | ✓ |
| swoole | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| sybase_ct | ✓ | ✓ | | | | | | | | |
| sysvmsg | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| sysvsem | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| sysvshm | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| tensor[*](#special-requirements-for-tensor) | | | | | ✓ | ✓ | ✓ | ✓ | | |
| tidy | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| timezonedb | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| uopz | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| uploadprogress | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| uuid | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| vips[*](#special-requirements-for-vips) | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| wddx | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | | |
| xdebug | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| xdiff | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xhprof | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| xlswriter | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xmldiff | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xmlrpc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xsl | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| yac | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| yaml | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| yar | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| zephir_parser | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| zip | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| zookeeper | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| zstd | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2019-12-17 09:26:35 +00:00
2022-06-11 15:26:01 +00:00
*Number of supported extensions: 125*
2018-04-11 15:39:10 +00:00
<!-- END OF EXTENSIONS TABLE -->
2018-04-12 07:50:14 +00:00
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):
2020-02-21 19:39:09 +00:00
```
$ 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]
2018-04-12 07:50:14 +00:00
```
2018-04-11 15:39:10 +00:00
2021-06-19 18:58:37 +00:00
## Configuration
2021-08-26 06:02:03 +00:00
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:
```sh
IPE_LZF_BETTERCOMPRESSION=1 install-php-extensions lzf
```
Here's the list of all the supported environment variables:
2021-06-19 18:58:37 +00:00
| Extension | Environment variable | Description |
|---|---|---|
2021-10-07 22:10:45 +00:00
| | `IPE_DONT_ENABLE=1` | By default the script will install and enable the extensions.< br /> If you want to only install them (without enabling them) you can set this environment variable.< br /> 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` ).< br /> **Beware**: installing some PHP extensions require that other PHP extensions are already enabled, so use this feature wisely. |
2021-08-13 06:54:09 +00:00
| | `IPE_KEEP_SYSPKG_CACHE=1` | By 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 |
2021-10-07 21:40:39 +00:00
| lzf | `IPE_LZF_BETTERCOMPRESSION=1` | By 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 |
2021-08-13 06:54:09 +00:00
| event | `IPE_EVENT_NAMESPACE=` ... | By default the `event` classes are defined in the root namespace. You can use this environment variable to specify a custom namespace |
2022-03-24 13:07:07 +00:00
| gd | `IPE_GD_WITHOUTAVIF=1` | Since PHP 8.1, gd supports the AVIF format. Enabling it requires compiling libaom/libdav1d/libyuv/libavif, which is time-consuming. You can disable AVIF support by setting this environment variable |
2022-03-24 13:04:40 +00:00
| oci8 & pdo_oci | `IPE_INSTANTCLIENT_BASIC=1` | The oci8 and pdo_oci PHP extensions require [Oracle Instant Client ](https://www.oracle.com/database/technologies/instant-client.html ). 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 |
2021-06-19 18:58:37 +00:00
2018-04-11 15:39:10 +00:00
## Special requirements
2021-03-02 20:31:48 +00:00
Some extensions have special requirements:
2018-04-11 15:39:10 +00:00
<!-- START OF SPECIAL REQUIREMENTS -->
<!-- ########################################################### -->
<!-- # # -->
<!-- # DO NOT EDIT THIS TABLE: IT IS GENERATED AUTOMATICALLY # -->
<!-- # # -->
<!-- # EDIT THE data/special - requirements FILE INSTEAD # -->
<!-- # # -->
<!-- ########################################################### -->
| Extension | Requirements |
2020-03-03 11:08:17 +00:00
|---|---|
2022-06-11 15:26:01 +00:00
| < a name = "special-requirements-for-ddtrace" ></ a > ddtrace | • Not available in `alpine3.7` docker images< br /> • Not available in `alpine3.8` docker images< br /> • Not available in `jessie` docker images |
2022-03-24 09:18:36 +00:00
| < a name = "special-requirements-for-geos" ></ a > geos | • Not available in `alpine3.7` docker images< br /> • Not available in `alpine3.8` docker images< br /> • Not available in `alpine3.9` docker images< br /> • Not available in `alpine3.10` docker images |
2022-06-13 07:42:16 +00:00
| < a name = "special-requirements-for-memprof" ></ a > memprof | • Not available in `alpine3.7` docker images< br /> • Not available in `alpine3.8` docker images< br /> • Not available in `alpine3.9` docker images< br /> • Not available in `alpine3.10` docker images< br /> • Not available in `alpine3.11` docker images< br /> • Not available in `alpine3.12` docker images< br /> • Not available in `alpine3.13` docker images< br /> • Not available in `alpine3.14` docker images< br /> • Not available in `alpine3.15` docker images |
2022-05-16 14:34:53 +00:00
| < a name = "special-requirements-for-parallel" > < / a > parallel | Requires images with PHP compiled with thread-safety enabled (`zts`) |
2022-04-21 14:17:15 +00:00
| < a name = "special-requirements-for-parle" ></ a > parle | Not available in `jessie` docker images |
2022-05-16 14:34:53 +00:00
| < a name = "special-requirements-for-pdo_sqlsrv" ></ a > pdo_sqlsrv | • Not available in `alpine3.7` docker images< br /> • Not available in `alpine3.8` docker images< br /> • Not available in ARM architectures |
| < a name = "special-requirements-for-pthreads" > < / a > pthreads | Requires images with PHP compiled with thread-safety enabled (`zts`) |
2022-04-05 12:37:33 +00:00
| < a name = "special-requirements-for-sodium" ></ a > sodium | Not available in `jessie` docker images |
2022-05-16 14:34:53 +00:00
| < a name = "special-requirements-for-sqlsrv" ></ a > sqlsrv | • Not available in `alpine3.7` docker images< br /> • Not available in `alpine3.8` docker images< br /> • Not available in `7.1-alpine3.9` docker images< br /> • Not available in `7.1-alpine3.10` docker images< br /> • Not available in ARM architectures |
2022-06-06 13:38:44 +00:00
| < a name = "special-requirements-for-tensor" ></ a > tensor | • Not available in `alpine3.15` docker images< br /> • Not available in `alpine3.16` docker images |
2021-08-26 08:03:10 +00:00
| < a name = "special-requirements-for-vips" ></ a > vips | • Not available in `alpine3.7` docker images< br /> • Not available in `alpine3.8` docker images< br /> • Not available in `alpine3.9` docker images< br /> • Not available in `jessie` docker images |
2018-04-11 15:39:10 +00:00
<!-- END OF SPECIAL REQUIREMENTS -->
2018-04-12 09:58:21 +00:00
2021-08-26 08:16:44 +00:00
### How do I know which Linux distribution I am using?
You can run this command:
```sh
cat /etc/os-release
```
For example:
- for Debian 11 (Bullseye) you'll see:
```sh
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
```
- for Alpine Linux 3.14 you'll see:
```sh
PRETTY_NAME="Alpine Linux v3.14"
```
2020-02-21 13:05:53 +00:00
## Tests
When submitting a pull request, a [GitHub Action ](https://github.com/mlocati/docker-php-extension-installer/blob/master/.github/workflows/test-extensions.yml ) 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 ](https://github.com/mlocati/docker-php-extension-installer/blob/master/.github/workflows/test-recent-extensions.yml ).
2020-02-22 19:42:50 +00:00
In case of failure, a message is sent to a [Telegram Channel ](https://t.me/docker_php_extension_installer ).
2020-02-21 13:05:53 +00:00
Feel free to subscribe to it to receive failure notifications.
2018-04-12 09:58:21 +00:00
## How to contribute
2019-12-20 17:26:26 +00:00
### Formatting code
2021-08-11 08:29:15 +00:00
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:
```diff
--- 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
```
2021-08-13 07:17:19 +00:00
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 `+`
2019-12-20 17:26:26 +00:00
2019-12-17 09:33:20 +00:00
### Adding support to a new PHP extension?
2019-12-11 11:57:53 +00:00
2019-12-17 09:33:20 +00:00
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`
2019-12-17 10:21:01 +00:00
See [this pull request ](https://github.com/mlocati/docker-php-extension-installer/pull/60 ) for an example.
2019-12-17 09:33:20 +00:00
### Changing the supported PHP versions for an already supported PHP extension?
1. change the `install-php-extensions` script
2019-12-18 15:45:20 +00:00
2. update the `data/supported-extensions` file, adding the new PHP version to the existing line corresponding to the updated extension
2019-12-17 10:21:01 +00:00
See [this pull request ](https://github.com/mlocati/docker-php-extension-installer/pull/62 ) for an example.
2019-12-17 09:33:20 +00:00
### 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
```
2019-12-18 15:45:20 +00:00
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
```
2019-12-17 09:33:20 +00:00
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-
```
2019-12-10 07:55:09 +00:00
2019-12-17 10:21:01 +00:00
See [this pull request ](https://github.com/mlocati/docker-php-extension-installer/pull/43 ) for an example.
2021-01-31 10:41:15 +00:00
### 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.
2021-08-13 07:17:19 +00:00
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](https://github.com/mlocati/pecl-info) you can find its source code).
2021-01-31 10:41:15 +00:00
2021-01-14 14:47:44 +00:00
## For the maintainers
See the [`MAINTAINERS.md` ](https://github.com/mlocati/docker-php-extension-installer/blob/master/MAINTAINERS.md ) file.
2019-12-10 07:55:09 +00:00
## Do you want to really say thank you?
You can offer me a [monthly coffee ](https://github.com/sponsors/mlocati ) or a [one-time coffee ](https://paypal.me/mlocati ) :wink: