Easily install PHP extension in Docker containers

Overview

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 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 section.

Usage

You have two ways to use this script within your Dockerfiles: 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 some Dockerfiles that install the GD and xdebug PHP extensions:

Downloading the script on the fly

With the Dockerfile

FROM php:7.2-cli

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

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

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.

In order to be sure the COPY instruction uses the very latest version, you can run:

docker pull mlocati/php-extension-installer

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

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 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

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
openswoole
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
sourceguardian
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
zephir_parser
zip
zookeeper
zstd

Number of supported extensions: 116

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:

Extension Environment variable Description
IPE_DONT_ENABLE=1 By 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 require that other PHP extensions are already enabled, so use this feature wisely.
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
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
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
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

Special requirements

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
tensor Not available in alpine3.15 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:

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 😉

Comments
  • xdebug installation fails on 8.x debian (missing lib/php-header.h)

    xdebug installation fails on 8.x debian (missing lib/php-header.h)

    Version of install-php-extensions

    v.1.5.29

    Error description

    Build fails in Docker build for RUN install-php-extensions xdebug. With fatal error: lib/php-header.h: No such file or directory

    See for example https://github.com/yiisoft/yii-docker/runs/7444548717?check_suite_focus=true#step:6:752 - also tested with the command above.

    2: compilation terminated.
    2: make: *** [Makefile:286: src/lib/lib.lo] Error 1
    2:  cc -I. -I/tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1 -I/tmp/pickle.tmp/pickle-7f747bef79dcb11e3af9f2d35a5c23574d431cf4/include -I/tmp/pickle.tmp/pickle-7f747bef79dcb11e3af9f2d35a5c23574d431cf4/main -I/tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1/src -I/tmp/pickle.tmp/pickle-7f747bef79dcb11e3af9f2d35a5c23574d431cf4/src -DHAVE_CONFIG_H -g -O2 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1/src/lib/usefulstuff.c -MMD -MF src/lib/usefulstuff.dep -MT src/lib/usefulstuff.lo  -fPIC -DPIC -o src/lib/.libs/usefulstuff.o
    2: make: *** [Makefile:304: src/lib/var.lo] Error 1
    2: make: *** [Makefile:262: src/base/base.lo] Error 1
    2: /tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1/src/lib/compat.c:42:10: fatal error: lib/php-header.h: No such file or directory
    2:    42 | #include "lib/php-header.h"
    2:       |          ^~~~~~~~~~~~~~~~~~
    2: compilation terminated.
    2: make: *** [Makefile:271: src/lib/compat.lo] Error 1
    2: /tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1/src/lib/str.c:23:10: fatal error: lib/php-header.h: No such file or directory
    2:    23 | #include "lib/php-header.h"
    2:       |          ^~~~~~~~~~~~~~~~~~
    2: compilation terminated.
    2: make: *** [Makefile:298: src/lib/str.lo] Error 1
    2: In file included from /tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1/src/lib/usefulstuff.c:33:
    2: /tmp/pickle.tmp/xdebug/xdebug-3.2.0alpha1/php_xdebug.h:28:10: fatal error: lib/php-header.h: No such file or directory
    2:    28 | #include "lib/php-header.h"
    2:       |          ^~~~~~~~~~~~~~~~~~
    2: compilation terminated.
    2: make: *** [Makefile:268: src/lib/usefulstuff.lo] Error 1The command '/bin/sh -c install-php-extensions         xdebug' returned a non-zero code: 1
    

    Docker image

    php:8.x

    Minimal Dockerfile

    FROM php:8.1-apache
    COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
    RUN install-php-extensions \
            xdebug
    
    bug 
    opened by schmunk42 19
  • Cleanup does not leave already installed packages

    Cleanup does not leave already installed packages

    As far as I can see cleanup (run by default since f164c691cdafd0b10242a4bb251ed6b96e59f2d8) does not leave already installed packages, but please correct me if I'm wrong. This means that the following will not work

    RUN apt-get install -y --no-install-recommends \
        a-package-i-need-later-on-and-is-needed-by-an-extension
    RUN install-php-extensions an-extension
    RUN something-that-needs-a-package-i-need-later-on-and-is-needed-by-an-extension
    

    Shouldn't just the delta of what was on the system and what is later on on the system be cleaned?

    opened by gisostallenberg 16
  • php-src master does not build on Alpine

    php-src master does not build on Alpine

    Version of install-php-extensions

    latest

    Error description

    see https://github.com/php/php-src/issues/8681

    the sockets ext needs newly linux-headers package on Alpine during the install

    Docker image

    latest

    Minimal Dockerfile

    No response

    bug 
    opened by mvorisek 14
  • Error on automation with Docker Hub but not when running manually

    Error on automation with Docker Hub but not when running manually

    I have an automated build for when new versions of PHP come out. It is based on the php:7.4-fpm-alpine image which currently uses Alpine 3.14.0 and PHP 7.4.21. Here is my Dockerfile.

    On our automated build, it appears that igbinary having an issue:

    running: make -j2
    /bin/sh /tmp/pear/temp/pear-build-defaultusericJmFk/igbinary-3.2.3/libtool --mode=compile cc -g -O2 -O2 -Wall -Wpointer-arith -Wcast-align -Wwrite-strings -Wswitch -finline-limit=10000 --param large-function-growth=10000 --param inline-unit-growth=10000 -I. -I/tmp/pear/temp/igbinary -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultusericJmFk/igbinary-3.2.3/include -I/tmp/pear/temp/pear-build-defaultusericJmFk/igbinary-3.2.3/main -I/tmp/pear/temp/igbinary -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/igbinary/src/php7/igbinary.c -o src/php7/igbinary.lo
    make: /bin/sh: Operation not permitted
    make: *** [Makefile:192: src/php7/igbinary.lo] Error 127
    ERROR: `make -j2' failed
    

    As I said, this is not happening when running manually.

    Do you think that Docker Hub could be caching an old image or Github version of docker-php-extension-installer?

    From the build.log it does look like it is using docker-php-extension-installer v.1.2.39.

    opened by if-kenn 13
  • Add support for grpc and protobuf

    Add support for grpc and protobuf

    I've moved to using your (excellent) script for installing my modules, and wanted to add a couple more that I can using.

    Test: gprc, opencensus, protobuf

    opened by mcfedr 13
  • GD broken for PHP 8.1

    GD broken for PHP 8.1

    Version of install-php-extensions

    1.4.17

    Error description

    The installation of ext-gd fails for PHP 8.1 (debian and alpine).

    ... Installing libavif -- The C compiler identification is GNU 10.2.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- libavif: Enabling warnings for GCC -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE
    -- Checking for module 'libyuv' -- No package 'libyuv' found -- libavif: libyuv (1812) found; libyuv-based fast paths enabled. -- libavif: Codec enabled: aom (encode/decode) -- Checking for module 'aom' -- Found aom, version 3.1.2 -- Found aom: /usr/local/lib/libaom.so (found version "3.1.2") -- Configuring done -- Generating done -- Build files have been written to: /tmp/src/tmp.6VuaXHSwW2/libavif-0.9.2/build Scanning dependencies of target avif [ 18%] Building C object CMakeFiles/avif.dir/src/alpha.c.o [ 18%] Building C object CMakeFiles/avif.dir/src/avif.c.o [ 18%] Building C object CMakeFiles/avif.dir/src/colr.c.o [ 25%] Building C object CMakeFiles/avif.dir/src/mem.c.o [ 31%] Building C object CMakeFiles/avif.dir/src/diag.c.o [ 37%] Building C object CMakeFiles/avif.dir/src/io.c.o [ 43%] Building C object CMakeFiles/avif.dir/src/obu.c.o [ 50%] Building C object CMakeFiles/avif.dir/src/rawdata.c.o [ 56%] Building C object CMakeFiles/avif.dir/src/read.c.o [ 62%] Building C object CMakeFiles/avif.dir/src/reformat.c.o [ 68%] Building C object CMakeFiles/avif.dir/src/reformat_libyuv.c.o [ 75%] Building C object CMakeFiles/avif.dir/src/stream.c.o In file included from /usr/include/libyuv/convert.h:19, from /usr/include/libyuv.h:16, from /tmp/src/tmp.6VuaXHSwW2/libavif-0.9.2/src/reformat_libyuv.c:36: /usr/include/libyuv/convert_argb.h:1947:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 1947 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:1962:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 1962 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:1977:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 1977 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:1992:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 1992 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2007:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2007 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2022:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2022 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2040:33: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2040 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2058:33: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2058 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2076:33: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2076 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2094:33: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2094 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2107:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2107 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2120:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2120 | FilterMode filter) ; | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2133:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2133 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum /usr/include/libyuv/convert_argb.h:2146:28: error: unknown type name 'FilterMode'; did you mean 'FilterModeEnum'? 2146 | FilterMode filter); | ^~~~~~~~~~ | FilterModeEnum make[2]: *** [CMakeFiles/avif.dir/build.make:212: CMakeFiles/avif.dir/src/reformat_libyuv.c.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [CMakeFiles/Makefile2:133: CMakeFiles/avif.dir/all] Error 2 make: *** [Makefile:149: all] Error 2

    Versions:

    root@a31f16c03420:/# php -v
    PHP 8.1.3 (cli) (built: Mar  3 2022 07:21:51) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.1.3, Copyright (c) Zend Technologies
    root@a31f16c03420:/# 
    root@a31f16c03420:/# install-php-extensions  
    install-php-extensions v.1.4.17
    root@a31f16c03420:/# 
    

    It's very easy to reproduce

    docker run --rm -ti php:8.1 bash
    # run
    curl -Lo /usr/local/bin/install-php-extensions 'https://github.com/mlocati/docker-php-extension-installer/releases/download/1.4.17/install-php-extensions' && chmod +x /usr/local/bin/install-php-extensions 
    install-php-extensions gd
    

    Docker image

    php:8.1-cli

    Minimal Dockerfile

    FROM php:8.1
    COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
    
    bug 
    opened by prilka 12
  • PHP 8.1 fpm - Alpine 3.15 Error AVIF Error

    PHP 8.1 fpm - Alpine 3.15 Error AVIF Error

    I am having the below error which i can pass with IPE_GD_WITHOUTAVIF=1.

    Installing libdav1d curl: (60) SSL certificate problem: self signed certificate in certificate chain More details here: https://curl.se/docs/sslcerts.html

    curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above. unzip: short read

    ERROR: Neither directory contains a build file meson.build.

    opened by yigitahmetsahin 11
  • Building extension from source

    Building extension from source

    First of all, thanks for this amazing utility. It makes installing PHP extensions a breeze. 😍

    I would like to request a feature: allow building some extensions from source.

    For example, the setup-php GitHub Action allows passing a list of extensions like this:

    with:
        extensions: gd,redis-5.3.5,memcached-php-memcached-dev/php-memcached@d3b8ce13f13cee3017aa8a00a0cfb2e7709154d8
    

    As you can see, memcached is installed from php-memcached-dev/php-memcached with commit d3b8ce13f13cee3017aa8a00a0cfb2e7709154d8.

    Is this something that can be added at some point?

    enhancement 
    opened by ruudk 11
  • cant run php from crons

    cant run php from crons

    Version of install-php-extensions

    lastes

    Error description

    i have this setup: https://github.com/arcanisgk/Minos

    FROM php:8.1.11-fpm
    
    WORKDIR "/application"
    
    COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
    
    RUN install-php-extensions pdo_mysql
    RUN install-php-extensions Reflection
    RUN install-php-extensions session
    RUN install-php-extensions SimpleXML
    RUN install-php-extensions SPL
    RUN install-php-extensions sqlite3
    RUN IPE_GD_WITHOUTAVIF=1 install-php-extensions gd
    RUN install-php-extensions curl
    RUN install-php-extensions imap
    RUN IPE_ICU_EN_ONLY=1 install-php-extensions intl
    RUN IPE_ICU_EN_ONLY=1 install-php-extensions http
    RUN install-php-extensions json
    RUN install-php-extensions mailparse
    RUN install-php-extensions mbstring
    RUN install-php-extensions readline
    RUN install-php-extensions soap
    RUN install-php-extensions xml
    RUN install-php-extensions xmlrpc
    RUN install-php-extensions bz2
    RUN install-php-extensions zlib
    RUN install-php-extensions dba
    RUN install-php-extensions ldap
    RUN install-php-extensions xdebug
    RUN install-php-extensions @composer
    
    RUN apt-get update
    RUN apt-get upgrade -y
    RUN apt-get update && apt-get -y install --no-install-recommends --fix-missing cron
    

    and this yml:

    version: "3.9"
    services:
      mysql:
        container_name: mysql
        image: 'mysql:8.0'
        working_dir: /application
        command: --default-authentication-plugin=mysql_native_password
        restart: always
        volumes:
          - '.:/application'
        environment:
          - MYSQL_ROOT_PASSWORD=1qazxsw22
          - MYSQL_DATABASE=minos
          - MYSQL_USER=minos
          - MYSQL_PASSWORD=1qazxsw22
        ports:
          - "3308:3306"
      webserver:
        container_name: webserver
        image: nginx:latest
        working_dir: /application
        volumes:
          - '.:/application'
          - './conf-example/docker-setup/nginx/nginx.conf:/etc/nginx/conf.d/default.conf'
        ports:
          - '8008:80'
        depends_on:
          - mysql
        links:
          - mysql
      php-fpm:
        build: ./
        working_dir: /application
        volumes:
          - '.:/application'
          - './conf-example/docker-setup/php-fpm/php-ini-overrides.ini:/etc/php/8.1/fpm/conf.d/99-overrides.ini'
      crontab-ui:
        ports:
          - '8009:8000'
        image: alseambusher/crontab-ui
        volumes:
          - '.:/application'
        links:
          - webserver
        depends_on:
          - webserver
      dozzle:
        container_name: dozzle-viewer
        hostname: dozzle
        image: amir20/dozzle
        ports:
          - "8010:8080"
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
    

    when i add a cron:

    image

    and try to run i get this error:

    image

    i have try to use phpor full path /usr/bin/php, checking i find that not exist a cli extension on list of installation... when i try to install cli extension i get this error:

    image

    Docker image

    php:8.1.11-fpm

    Minimal Dockerfile

    No response

    bug 
    opened by arcanisgk 10
  • `intl` cannot be build on Alpine & PHP 7.2

    `intl` cannot be build on Alpine & PHP 7.2

    Version of install-php-extensions

    latest

    Error description

    see https://github.com/mvorisek/image-php/runs/5755017479?check_suite_focus=true#step:5:5916

     /usr/src/php/ext/intl/collator/collator_sort.c: In function 'zif_collator_sort':
    /usr/src/php/ext/intl/collator/collator_sort.c:349:26: error: 'TRUE' undeclared (first use in this function)
      349 |  collator_sort_internal( TRUE, INTERNAL_FUNCTION_PARAM_PASSTHRU );
          |                          ^~~~
    /usr/src/php/ext/intl/collator/collator_sort.c:349:26: note: each undeclared identifier is reported only once for each function it appears in
    /usr/src/php/ext/intl/collator/collator_sort.c: In function 'zif_collator_asort':
    /usr/src/php/ext/intl/collator/collator_sort.c:543:26: error: 'FALSE' undeclared (first use in this function)
      543 |  collator_sort_internal( FALSE, INTERNAL_FUNCTION_PARAM_PASSTHRU );
          |                          ^~~~~
    make: *** [Makefile:204: collator/collator_sort.lo] Error 1
    

    Docker image

    Alpine & PHP 7.2

    Minimal Dockerfile

    No response

    bug waiting for feedback 
    opened by mvorisek 10
  • Tag releases on master branch

    Tag releases on master branch

    It would be great to be able to use a specific version of the script when building docker images rather than just a general 'latest'. Moving forward this might also be helpful to maintainers in being able to remove support for older php versions and distros

    opened by mcfedr 10
  • Odd error installing xdebug while building an 8.2 container in gitlab CI

    Odd error installing xdebug while building an 8.2 container in gitlab CI

    Version of install-php-extensions

    v.1.5.51

    Error description

    When attempting to install xdebug in php:8.2 while building a container in gitlab CI I'm getting an odd error:

    2: /tmp/pickle.tmp/xdebug/xdebug-3.2.0/src/lib/usefulstuff.c:1153: error: unterminated #else
    2:  1153 | #ifdef ZEND_HASH_GET_APPLY_COUNT /* PHP 7.2 or earlier recursion protection */
    2:       |
    2: make: *** [Makefile:270: src/lib/usefulstuff.lo] Error 1The command '/bin/sh -c /usr/local/bin/install-php-extensions ${EXTENSIONS} @composer' returned a non-zero code: 1
    

    The full output can be seen here: https://gitlab.com/portlandlabs/containers/-/jobs/3479191268

    For some reason I'm able to build this container without issue locally, this issue only shows up in gitlab CI.

    Docker image

    php:8.2

    Minimal Dockerfile

    https://gitlab.com/portlandlabs/containers/-/blob/main/php/default/Dockerfile
    
    where:
    - `BASE_IMAGE` = `php:8.2`
    - `EXTENSIONS` = `mbstring curl intl gd xml zip bz2 pdo_mysql xdebug redis amqp`
    
    bug 
    opened by KorvinSzanto 6
  • Installing extensions behind firewall.

    Installing extensions behind firewall.

    Version of install-php-extensions

    mlocati/php-extension-installer:1.5

    Error description

    Our CI is in a protected firewall which limits request that could go outside. Is there a way to not make request to github.com?

    [stage-0 2/2] RUN  --mount=type=bind,from=harbor.noones.tools/docker-hub-proxy/mlocati/php-extension-installer:1.5,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions       install-php-extensions apcu-5.1.22 redis-5.3.7
    #6 sha256:3b8c5beaf162b8047ba99cbc0d1635177e0ca3ad0a044617f30a459ff2485e5e
    #6 0.229 install-php-extensions v.1.5.49
    #6 0.229 #StandWithUkraine
    #6 132.2 curl: (28) Failed to connect to github.com port 443 after 130412 ms: Couldn't connect to server
    #6 ERROR: executor failed running [/bin/sh -c install-php-extensions apcu-5.1.22 redis-5.3.7]: exit code: 28
    

    Docker image

    php:8.1-cli-alpine

    Minimal Dockerfile

    FROM php:8.1-cli-alpine
    
    RUN  --mount=type=bind,from=mlocati/php-extension-installer:1.5,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \
          install-php-extensions apcu-5.1.22 redis-5.3.7
    
    bug 
    opened by Legion112 5
  • Support cassandra

    Support cassandra

    Actual src https://github.com/nano-interactive/ext-cassandra/tree/v1.3.x

    PECL is outdated and not support PHP 8.x https://pecl.php.net/package/cassandra

    https://github.com/nano-interactive/ext-cassandra/issues/30

    enhancement 
    opened by maxm86545 2
  • Unable to install extensions on PHP 8.1

    Unable to install extensions on PHP 8.1

    Version of install-php-extensions

    v.1.5.37

    Error description

    The command install-php-extensions gd intl pdo_mysql opcache zip is not working in a php:8.1-fpm docker container. I checked and each of these extensions appears to be supported for building in PHP 8.1 so I'm not sure the issue.

    I get the following output after trying to install the extensions:

    failed to solve: executor failed running [/bin/sh -c install-php-extensions gd intl pdo_mysql opcache zip]: exit code: 1

    Along with a bunch of messages like this:

    #0 111.9 [0/1] Re-running CMake...
    #0 111.9 --- aom_configure: Detected CPU: x86_64
    #0 112.4 -- Configuring done
    #0 112.5 -- Generating done
    #0 112.5 -- Build files have been written to: /tmp/src/tmp.vsLIEPDPzl/my.build
    #0 112.5 [0/1] Re-running CMake...
    #0 112.5 --- aom_configure: Detected CPU: x86_64
    #0 113.0 -- Configuring done
    #0 113.1 -- Generating done
    #0 113.1 -- Build files have been written to: /tmp/src/tmp.vsLIEPDPzl/my.build
    #0 113.1 [0/1] Re-running CMake...
    #0 113.1 --- aom_configure: Detected CPU: x86_64
    #0 113.6 -- Configuring done
    #0 113.7 -- Generating done
    #0 113.7 -- Build files have been written to: /tmp/src/tmp.vsLIEPDPzl/my.build
    #0 113.7 [0/1] Re-running CMake...
    #0 113.7 --- aom_configure: Detected CPU: x86_64
    #0 114.2 -- Configuring done
    #0 114.3 -- Generating done
    #0 114.3 -- Build files have been written to: /tmp/src/tmp.vsLIEPDPzl/my.build
    #0 114.3 [0/1] Re-running CMake...
    #0 114.3 --- aom_configure: Detected CPU: x86_64
    #0 114.8 -- Configuring done
    #0 114.8 -- Generating done
    #0 114.9 -- Build files have been written to: /tmp/src/tmp.vsLIEPDPzl/my.build
    #0 114.9 [0/1] Re-running CMake...
    #0 114.9 --- aom_configure: Detected CPU: x86_64
    #0 115.4 -- Configuring done
    #0 115.4 -- Generating done
    #0 115.5 -- Build files have been written to: /tmp/src/tmp.vsLIEPDPzl/my.build
    

    Docker image

    php:8.1-fpm - same result on php:8.1-cli

    Minimal Dockerfile

    FROM  php:8.1-fpm
    
    COPY --from=mlocati/php-extension-installer:latest /usr/bin/install-php-extensions /usr/bin/
    
    RUN apt update && apt install git unzip -yq && \
        apt-get clean autoclean; apt-get autoremove --yes; rm -rf /var/lib/{apt,dpkg,cache,log}/
    
    RUN install-php-extensions gd intl pdo_mysql opcache zip
    
    bug 
    opened by MichaelMackus 14
  • Respect / take into account Proxy Settings if given

    Respect / take into account Proxy Settings if given

    I was facing a problem when using the installer to install mcrypt on a more encapsulated system which requires a proxy server to be used. As this server varies among our landscape, we hand it into the build process by using --build-arg when doing a docker build.

    This worked quite well so far, but now failed when trying to install mcrypt. Everything seemed to work, even the download of external packages required by the build process takes into account these settings if given. It took me a bit of research to fully understand the issue: The environment variables are not taken into account by pear, which is used to install the mcrypt extension. Current workaround is to place the following in the Dockerfile:

    RUN pear config-set http_proxy $http_proxy

    If I can find the time I will also create patch/pull request to have this kind of recognition directly built into the extension installer.

    enhancement 
    opened by bahag-schlachterk 0
Releases(1.5.52)
Owner
Michele Locati
Having fun with coding since 1988
Michele Locati
Docker-magento2 - 🐳 Docker containers with all required Magento 2 dependencies installed available as FPM through Nginx and CLI

Magento 2 Docker A collection of Docker images for running Magento 2 through nginx and on the command line. Quick Start cp composer.env.sample compose

Meanbee 454 Dec 27, 2022
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
A Magento Development Environment Made of Docker Containers

Docker for Magento 1 Extension Development Tl;dr How do I use this? Clone it. Type docker-compose up -d. Install a Magento Mount your file share. Deve

Michael A. Smith 99 May 10, 2021
OSX/Linux Docker containers installer for Magento 2

Magento 2 OSX/Linux Docker Requirements MacOS: Docker, docker-sync, Git Linux: Docker, Docker-compose, Git on Debian based OS (Example: Ubuntu, Linux

Osiozekhai Aliu 54 Dec 10, 2022
Main ABRouter product repository that contains docker-compose file and orchestrates the project containers.

ABRouter-Compose ?? ABRouter is the open-source tool to perform and track A/B tests which is also known as the experiments. Additionally, feature flag

ABRouter 29 Dec 22, 2022
This module adds a command to easily generate "modules" in Laravel and install them using composer.

Laravel Module Create This module adds a command to easily generate "modules" in Laravel and install them using composer Installation Simply install t

null 2 Feb 18, 2022
Docker-magento - Docker image for Magento 1.6 to 1.9

Docker image for Magento 1.x This repo creates a Docker image for Magento 1.x. Please note The primary goal of this repo is to create Docker images fo

Fu Cheng 144 Nov 18, 2022
🐋 This project aims to broaden knowledge of system administration by using Docker: virtualizing several Docker images, creating them in a new personal virtual machine.

?? This project aims to broaden knowledge of system administration by using Docker: virtualizing several Docker images, creating them in a new personal virtual machine.

Anton Kliek 1 Jan 26, 2022
Nuber is an open source container management platform it provides a front end to manage your own cloud infrastructure, using Linux Containers virtualization technology

Nuber is an open source container management platform it provides a front end to manage your own cloud infrastructure, using Linux Containers virtualization technology

null 33 Dec 14, 2022
This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project

psr-container-doctrine: Doctrine Factories for PSR-11 Containers Doctrine factories for PSR-11 containers. This package provides a set of factories to

Roave, LLC 84 Dec 14, 2022
Spin up a working Statamic instance quickly & easily with Docker

Spin Up Statamic Allows you to create your own self-contained Statamic project complete site config, Antlers/Blade/Twig template files, assets, and de

nystudio107 11 Jun 2, 2023
Magento 2 Extension to cleanup admin menu and Store > Configuration area by arranging third party extension items.

Clean Admin Menu - Magento 2 Extension It will merge all 3rd party extension's menu items in backend's primary menu to a common menu item named "Exten

RedChamps 109 Jan 3, 2023
Magento 2 Blog Extension is a better blog extension for Magento 2 platform. These include all useful features of Wordpress CMS

Magento 2 Blog extension FREE Magento 2 Better Blog by Mageplaza is integrated right into the Magento backend so you can manage your blog and your e-c

Mageplaza 113 Dec 14, 2022
Magento 2 Megamenu extension is an indispensable component, and plays the role of website navigation to help customers easily categorize and find information

Mageno 2 Mega Menu (Magicmenu) helps you create neat and smart navigation menus to display the main categories on your website.

https://magepow.com 35 Dec 1, 2022
Phalcon 3.x BB Debugger Strong and easy install.

Phalcon BB Debugger Phalcon Version: 3.x BB Debugger Version: 1.0.3 Change Log See ChangeLog What is BB Debugger ? The bb debugger, written for the ph

İsmail 6 Oct 7, 2022
Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Strategery 123 Nov 20, 2021
Magento 2 Bash Install/Restore Script

Magento 2 Bash Install/Restore Script This script is designed to simplify the installation process of Magento 2 and rapid deployment of merchant code

Yarik Voronoy 80 Sep 30, 2022