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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw that there is no disable script here - ideally, it'd be great to replicate both php5enmod and php5dismod functionality.
I created a disable script based on docker-php-ext-enable and am copying it in my build. The script just looks for the existence of the extension ini file and removes it - but not sure if there is a more ideal way to handle this? Willing to PR it, if there's any interest.
The use case for me was to be able to enable or disable xdebug on the fly when running PHPUnit:
docker exec -ti php sh -c "docker-php-ext-disable xdebug && vendor/bin/phpunit
Reacted by Dalibor Petras, kodeart, daniele, Pravin Dahal, Přemysl Karbula, 少湖说, Christian Sciberras, Mandy Schoep, Alex Teterin, Łukasz Zakrzewski and 10 more
I'm honestly a little -1 on adding this. Enabling an extension in a generic way is simple (requires getting extension=xxx.so into the PHP configuration somewhere). Disabling in a fully generic way is not nearly as simple, so I would actually recommend using --ini-name (from #178) to accomplish this more easily.
Yes, furthermore there's no good reason to disable an extension in fact. If you use the same container for tests/dev & production (which is pretty cool), you can imagine running php differently depending on your environment.
It's easier for example to run php php -d 'extension=xdebug.so' myscript.php when developing your app then running just php myscript.php in production.
+1 It is useful if you create your own images for dev/prod. If dev extends the production image, it's great to disable something from production, i.e.
# in dev Dockerfile
FROM my-production-image
RUN docker-php-ext-disable opcache
Reacted by Jorge Matricali, Roma Hlushko, Luke Duda, Andreas Schroth, Vlad Tuznychenko, David Naber, Michał Mieluch, Binyamin Laukstein, Antonie Potgieter, pmsl987 and 7 more
@kodeart yes... but why not producing a dedicated image for dev and another one for prod? Very easy with automated builds & tags.
Reacted by João Carlos, Mitchell Bundy, Seth Miller, Andreas Schroth, Vlad Tuznychenko, Alex Skripov, Michał Mieluch, Paul Wong-Gibbs, gaotao, Allan Paiste and 5 more
Given that #178 added --ini-name for explicitly controlling the exact filename docker-php-ext-enable creates (and that the filenames it uses are already trivially deterministic), I'm going to close this with the recommendation that users who need to disable extensions after previously enabling them simply use rm on the appropriate file (or sed, if they've added additional configuration to the file since enabling the extension). Thanks!
Something of note where people may want to specifically disabled xdebug you can set the environment variable XDEBUG_MODE=off and that will turn off xdebug on-the-fly. This was my primary purposed for investigating a docker-php-ext-disable method.
Something of note where people may want to specifically disabled xdebug you can set the environment variable XDEBUG_MODE=off and that will turn off xdebug on-the-fly. This was my primary purposed for investigating a docker-php-ext-disable method.
Just to chime in here on an old comment... @tianon
I'm looking for a way to enable / disable an extension after it was already configured / installed etc. It's common to enable/disable xdebug quickly for an image and we currently handle this by utilizing docker-php-ext-enable xdebug vs rm "/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"; but this feels clunky having to download the APK everytime. I'd like to keep the actual module after installation but add / delete the .ini only. That would allow far easier on/offline working and keep the xdebug (enabled / disabled) features.
I know i'm almost there, but having the docker-php-ext-enable xdebug conditionally check if the .SO is already there before downloading would suffice for my usecase. Any chance this might be something you'd consider?
I think instead of using docker-php-ext-enable for the "toggling" use case, you might instead rename the file with a .disabled suffix (ie, rename back and forth instead of deleting and recreating).
Activity
isp0000 commentedon May 2, 2016
@kmfk why not add your script as pull request?
tianon commentedon May 2, 2016
I'm honestly a little -1 on adding this. Enabling an extension in a generic way is simple (requires getting
extension=xxx.sointo the PHP configuration somewhere). Disabling in a fully generic way is not nearly as simple, so I would actually recommend using--ini-name(from #178) to accomplish this more easily.shouze commentedon May 25, 2016
Yes, furthermore there's no good reason to disable an extension in fact. If you use the same container for tests/dev & production (which is pretty cool), you can imagine running php differently depending on your environment.
It's easier for example to run php
php -d 'extension=xdebug.so' myscript.phpwhen developing your app then running justphp myscript.phpin production.kodeart commentedon Jun 8, 2016
+1 It is useful if you create your own images for dev/prod. If dev extends the production image, it's great to disable something from production, i.e.
shouze commentedon Jun 8, 2016
@kodeart yes... but why not producing a dedicated image for dev and another one for prod? Very easy with automated builds & tags.
pproenca commentedon Jul 22, 2016
@kmfk @tianon I've opened a pull request which introduces
docker-php-ext-disablein #270tianon commentedon Dec 22, 2017
Given that #178 added
--ini-namefor explicitly controlling the exact filenamedocker-php-ext-enablecreates (and that the filenames it uses are already trivially deterministic), I'm going to close this with the recommendation that users who need to disable extensions after previously enabling them simply usermon the appropriate file (orsed, if they've added additional configuration to the file since enabling the extension). Thanks!timnolte commentedon Sep 17, 2023
Something of note where people may want to specifically disabled xdebug you can set the environment variable
XDEBUG_MODE=offand that will turn off xdebug on-the-fly. This was my primary purposed for investigating adocker-php-ext-disablemethod.LaurentGoderre commentedon Sep 18, 2023
Thanks for sharing this!
jonpontet commentedon Dec 18, 2023
Or
xdebug.mode=offReference
fruitl00p commentedon Oct 1, 2024
Just to chime in here on an old comment... @tianon
I'm looking for a way to enable / disable an extension after it was already configured / installed etc. It's common to enable/disable xdebug quickly for an image and we currently handle this by utilizing docker-php-ext-enable xdebug vs rm "/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"; but this feels clunky having to download the APK everytime. I'd like to keep the actual module after installation but add / delete the .ini only. That would allow far easier on/offline working and keep the xdebug (enabled / disabled) features.
I know i'm almost there, but having the docker-php-ext-enable xdebug conditionally check if the .SO is already there before downloading would suffice for my usecase. Any chance this might be something you'd consider?
tianon commentedon Oct 1, 2024
I think instead of using
docker-php-ext-enablefor the "toggling" use case, you might instead rename the file with a.disabledsuffix (ie, rename back and forth instead of deleting and recreating).cha0s commentedon Oct 20, 2025