2018-04-12 07:25:43 +00:00
[![TravisCI Build Status ](https://travis-ci.org/mlocati/docker-php-extension-installer.svg?branch=master )](https://travis-ci.org/mlocati/docker-php-extension-installer)
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/ ).
2019-12-10 07:55:09 +00:00
The script works both for Alpine and Debian Linux.
2018-04-11 15:39:10 +00:00
## Usage
Here's a sample Dockerfile that installs the GD and xdedub extensions inside a docker image:
```
FROM php:7.2-cli
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
2018-04-12 12:37:58 +00:00
RUN chmod uga+x /usr/local/bin/install-php-extensions & & sync & & \
2018-04-11 15:45:25 +00:00
install-php-extensions gd xdebug
2018-04-11 15:39:10 +00:00
```
2019-10-09 15:11:51 +00:00
Installation via COPY --from
```
FROM php:7.2-cli
2019-10-10 06:49:44 +00:00
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
2019-10-09 15:11:51 +00:00
RUN install-php-extensions gd xdebug
```
Continue implementing Alpine support
Test: amqp, apcu, bcmath, bz2, calendar, cmark, dba, enchant, exif, gd, gettext, gmp, igbinary, imagick, imap
2019-12-10 08:06:30 +00:00
`install-php-extensions` will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed.
2018-06-28 07:46:14 +00:00
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 # -->
<!-- # # -->
<!-- ########################################################### -->
2019-10-10 16:53:15 +00:00
| Extension | PHP 5.6 | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| amqp | V | V | V | V | V | V |
| apcu | V | V | V | V | V | V |
| bcmath | V | V | V | V | V | V |
| bz2 | V | V | V | V | V | V |
| calendar | V | V | V | V | V | V |
| cmark | | V | V | V | V | V |
| dba | V | V | V | V | V | V |
| enchant | V | V | V | V | V | V |
| exif | V | V | V | V | V | V |
| gd | V | V | V | V | V | V |
| gettext | V | V | V | V | V | V |
| gmp | V | V | V | V | V | V |
2019-12-17 09:10:34 +00:00
| grpc | V | V | V | V | V | V |
2019-12-24 14:33:37 +00:00
| http | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| igbinary | V | V | V | V | V | V |
| imagick | V | V | V | V | V | V |
| imap | V | V | V | V | V | V |
| interbase | V | V | V | V | V | |
| intl | V | V | V | V | V | V |
| ldap | V | V | V | V | V | V |
2019-12-23 16:44:38 +00:00
| mailparse | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| mcrypt | V | V | V | V | V | V |
2019-12-20 16:21:34 +00:00
| memcache | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| memcached | V | V | V | V | V | V |
2019-12-12 11:56:15 +00:00
| mongo | V | | | | | |
| mongodb | V | V | V | V | V | V |
2019-10-11 13:27:29 +00:00
| msgpack | V | V | V | V | V | V |
2019-12-11 22:21:15 +00:00
| mssql | V | | | | | |
2019-10-10 16:53:15 +00:00
| mysql | V | | | | | |
| mysqli | V | V | V | V | V | V |
| odbc | V | V | V | V | V | V |
| opcache | V | V | V | V | V | V |
2019-12-17 10:17:23 +00:00
| opencensus | | V | V | V | V | V |
2019-10-11 06:23:49 +00:00
| parallel | | | V | V | V | V |
2019-10-10 16:53:15 +00:00
| pcntl | V | V | V | V | V | V |
| pcov | | V | V | V | V | V |
| pdo_dblib | V | V | V | V | V | V |
| pdo_firebird | V | V | V | V | V | V |
| pdo_mysql | V | V | V | V | V | V |
| pdo_odbc | V | V | V | V | V | V |
| pdo_pgsql | V | V | V | V | V | V |
2019-10-10 17:37:00 +00:00
| pdo_sqlsrv | | V | V | V | V | V |
| pgsql | V | V | V | V | V | V |
2019-12-24 09:40:59 +00:00
| propro | V | V | V | V | V | V |
2019-12-17 09:10:34 +00:00
| protobuf | V | V | V | V | V | V |
2019-10-10 17:37:00 +00:00
| pspell | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| pthreads | V | V | | | | |
2019-12-24 09:28:02 +00:00
| raphf | V | V | V | V | V | V |
2019-12-19 09:23:49 +00:00
| rdkafka | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| recode | V | V | V | V | V | |
2019-10-10 17:37:00 +00:00
| redis | V | V | V | V | V | V |
| shmop | V | V | V | V | V | V |
| snmp | V | V | V | V | V | V |
| soap | V | V | V | V | V | V |
| sockets | V | V | V | V | V | V |
| solr | V | V | V | V | V | V |
| sqlsrv | | V | V | V | V | V |
| ssh2 | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| sybase_ct | V | | | | | |
2019-10-10 17:37:00 +00:00
| sysvmsg | V | V | V | V | V | V |
| sysvsem | V | V | V | V | V | V |
| sysvshm | V | V | V | V | V | V |
| tidy | V | V | V | V | V | V |
| timezonedb | V | V | V | V | V | V |
| uopz | V | V | V | V | V | V |
| uuid | V | V | V | V | V | V |
2019-10-10 16:53:15 +00:00
| wddx | V | V | V | V | V | |
2019-10-10 17:37:00 +00:00
| xdebug | V | V | V | V | V | V |
| xmlrpc | V | V | V | V | V | V |
| xsl | V | V | V | V | V | V |
| yaml | V | V | V | V | V | V |
| zip | V | V | V | V | V | V |
2019-12-17 09:26:35 +00:00
2019-12-24 14:33:37 +00:00
*Number of supported extensions: 72*
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):
```sh
docker run --rm -it php:7.2-cli php -m
```
2018-04-11 15:39:10 +00:00
## Special requirements
Some extension has special requirements:
<!-- START OF SPECIAL REQUIREMENTS -->
<!-- ########################################################### -->
<!-- # # -->
<!-- # DO NOT EDIT THIS TABLE: IT IS GENERATED AUTOMATICALLY # -->
<!-- # # -->
<!-- # EDIT THE data/special - requirements FILE INSTEAD # -->
<!-- # # -->
<!-- ########################################################### -->
| Extension | Requirements |
|:---:|:---:|
2019-10-11 06:23:49 +00:00
| parallel | Requires images with PHP compiled with thread-safety enabled (`zts`). |
2018-04-11 15:39:10 +00:00
| pthreads | Requires images with PHP compiled with thread-safety enabled (`zts`). |
<!-- END OF SPECIAL REQUIREMENTS -->
2018-04-12 09:58:21 +00:00
## How to contribute
2019-12-20 17:26:26 +00:00
### Formatting code
Before submitting any pull request, be sure to execute the `lint` script in the `scripts` directory (or `lint.bat` on Windows).
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.
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: