giansalex / docker-php-ext-install.md
This comment has been minimized.
Copy link Quote reply
telepresencebot2 commented Jan 20, 2019
This comment has been minimized.
Copy link Quote reply
mahavirhirani commented Dec 10, 2019
This comment has been minimized.
Copy link Quote reply
AlekseyBusarev commented Dec 22, 2019
Replace from mysql-client to mariadb-client for php:7.1-apache. It’s works for me.
Thanks. It’s the really helpful note.
This comment has been minimized.
Copy link Quote reply
guazontsubasa commented Apr 10, 2020 •
This comment has been minimized.
Copy link Quote reply
giansalex commented Apr 10, 2020
This comment has been minimized.
Copy link Quote reply
ivano9 commented Dec 1, 2020 •
Openssl extension are supported by the docker-php-ext?
This comment has been minimized.
Copy link Quote reply
giansalex commented Dec 1, 2020
@ivano9 openssl is included in base image.
This comment has been minimized.
Copy link Quote reply
joaomarcosmareto commented Jan 22, 2021
Can anyone provide the code to get the cas extension php-cas?
This comment has been minimized.
Copy link Quote reply
DurandSacha commented Apr 9, 2021
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Docker install php extension
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.
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. 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.
For example, here are two Dockerfile s that install the GD and xdebug PHP extensions:
Downloading the script on the fly
Copying the script from a Docker image
When building locally, be sure you have the latest version of the mlocati/php-extension-installer image by running:
otherwise the COPY instruction could use a previously downloaded, outdated version of the image stored in the local docker cache.
Installing specific versions of an extension
The script also supports resolving compatible versions by prefixing the version with a caret ( ^ ). For example:
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:
You can also install composer, and you also can specify a major version of it, or a full version.
Supported PHP extensions
| 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 |
|---|---|---|---|---|---|---|---|---|---|
| amqp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| apcu | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| apcu_bc | ✓ | ✓ | ✓ | ✓ | ✓ | ||||
| ast | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| bcmath | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| blackfire | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| bz2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| calendar | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| cmark | ✓ | ✓ | ✓ | ✓ | ✓ | ||||
| csv | ✓ | ✓ | ✓ | ||||||
| dba | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| decimal | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| ds | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| enchant | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ev | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| event | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| excimer | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| exif | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ffi | ✓ | ✓ | ✓ | ||||||
| gd | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gearman | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| geoip | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| geospatial | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gettext | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gmagick | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gmp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| gnupg | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| grpc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| http | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| igbinary | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| imagick | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| imap | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| inotify | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| interbase | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| intl | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ioncube_loader | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| jsmin | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| json_post | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ldap | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| lzf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mailparse | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| maxminddb | ✓ | ✓ | ✓ | ✓ | ✓ | ||||
| mcrypt | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| memcache | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| memcached | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mongo | ✓ | ✓ | |||||||
| mongodb | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mosquitto | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| msgpack | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mssql | ✓ | ✓ | |||||||
| mysql | ✓ | ✓ | |||||||
| mysqli | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| oauth | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| oci8 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| odbc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| opcache | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| opencensus | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| parallel* | ✓ | ✓ | ✓ | ✓ | |||||
| pcntl | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pcov | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| pdo_dblib | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| pdo_firebird | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_mysql | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_oci | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| pdo_odbc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_pgsql | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pdo_sqlsrv* | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| pgsql | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| propro | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| protobuf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| pspell | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| pthreads* | ✓ | ✓ | ✓ | ||||||
| raphf | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| rdkafka | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| recode | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| redis | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| seaslog | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| shmop | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| smbclient | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| snmp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| snuffleupagus | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| soap | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| sockets | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| solr | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| spx | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| sqlsrv* | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| ssh2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| stomp | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| swoole | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| sybase_ct | ✓ | ✓ | |||||||
| sysvmsg | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| sysvsem | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| sysvshm | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| tensor | ✓ | ✓ | ✓ | ✓ | |||||
| tidy | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| timezonedb | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| uopz | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| uploadprogress | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| uuid | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| vips* | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| wddx | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| xdebug | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xhprof | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xlswriter | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| xmldiff | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| xmlrpc | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| xsl | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| yac | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| yaml | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| yar | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| zip | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| zookeeper | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| zstd | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Number of supported extensions: 113
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):
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 the list of all the supported environment variables:
Some extensions have special requirements:
| Extension | Requirements |
|---|---|
| parallel | Requires images with PHP compiled with thread-safety enabled ( zts ). |
| pdo_sqlsrv | • Not available in alpine3.7 docker images • Not available in alpine3.8 docker images • Not available in bullseye docker images |
| pthreads | Requires images with PHP compiled with thread-safety enabled ( zts ). |
| sqlsrv | • Not available in alpine3.7 docker images • Not available in alpine3.8 docker images • Not available in 7.1-alpine3.9 docker images • Not available in 7.1-alpine3.10 docker images • Not available in bullseye docker images |
| vips | • Not available in alpine3.7 docker images • Not available in alpine3.8 docker images • Not available in alpine3.9 docker images • Not available in jessie docker images |
How do I know which Linux distribution I am using?
You can run this command:
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.
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:
Adding support to a new PHP extension?
See this pull request for an example.
Changing the supported PHP versions for an already supported PHP 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:
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:
See this pull request for an example.
PHP requirements and configure options