Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for disable PHP additional extensions via PHP_DISABLE_EXTENSIONS environment variable #46

Merged
merged 2 commits into from
Oct 20, 2024

Conversation

joseluisq
Copy link
Owner

@joseluisq joseluisq commented Oct 5, 2024

This PR supports disabling additional 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

Extensions list per PHP version

The extensions list per PHP version can be found in the extensions.txt file of every corresponding version directory. For example 8.3-fpm/extensions.txt

It resolves #40.

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
@joseluisq joseluisq added the enhancement New feature or request label Oct 5, 2024
@joseluisq joseluisq self-assigned this Oct 5, 2024
@joseluisq joseluisq linked an issue Oct 5, 2024 that may be closed by this pull request
@joseluisq joseluisq added the v8.3 label Oct 5, 2024
@joseluisq joseluisq changed the title Support for disable PHP extensions via PHP_DISABLE_EXTENSIONS environment variable Support for disable PHP additional extensions via PHP_DISABLE_EXTENSIONS environment variable Oct 19, 2024
@joseluisq joseluisq force-pushed the disable-php-extensions-support branch from c9001ce to 6b70712 Compare October 19, 2024 21:34
@joseluisq joseluisq merged commit 83d9123 into master Oct 20, 2024
15 checks passed
@joseluisq joseluisq deleted the disable-php-extensions-support branch October 20, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PSR conflict with Symfony
1 participant