alpine-php-fpm icon indicating copy to clipboard operation
alpine-php-fpm copied to clipboard

Support for disable PHP extensions via `PHP_DISABLE_EXTENSIONS` environment variable

Open joseluisq opened this issue 1 year ago • 0 comments

This PR supports disabling PHP extensions via the new PHP_DISABLE_EXTENSIONS environment variable.

The PHP extensions can be disabled at startup by providing the PHP_DISABLE_EXTENSIONS environment variable with one or more valid extension names. For example PHP_DISABLE_EXTENSIONS=amqp,mongodb,zstd,psr,exif,bz2.

Valid extension names can be found by using php -m. For example docker run --rm joseluisq/php-fpm:8.3 php -m | grep "exif".

Example:

$ docker run --rm -p 8088:80 -e PHP_DISABLE_EXTENSIONS="amqp,mongodb,zstd" \
       joseluisq/php-fpm:8.3.12 sh -c "echo '<?php phpinfo();' > index.php; php -S [::]:80 -t ."

Disabling 3 extension(s): amqp mongodb zstd
OK: 'amqp' disabled
OK: 'mongodb' disabled
OK: 'zstd' disabled

Verifying PHP extensions...
PHP 8.3.12 (cli) (built: Sep 26 2024 23:00:14) (NTS) Copyright (c) The PHP Group
Zend Engine v4.3.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.12, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
[05-Oct-2024 02:37:25] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful Tests were successful!
[Sat Oct  5 02:37:25 2024] PHP 8.3.12 Development
Server (http://[::]:80) started

It resolves #40.

joseluisq avatar Oct 05 '24 02:10 joseluisq