I have made super simple OS independent phpenmod.
Https://github.com/legale/phpenmod
I'm fan of this idea. I miss this in any other non-debian distro.
What nobody mentioned yet, similar script (dockerphp-ext-enable)
is used in PHP docker images. You can check them out at
https://github.com/docker-library/php/blob/master/7.3/alpine3.9/cli/docker-php-ext-enableHowever, enabling extensions in PHP via CLI is easy.
It's just php -dextension=extension.so. What isn't easy, is DISABLING them.This is very important to do when you have profiling/debugging extensions
like xdebug enabled.Currently, PHP community needs to do workaround gymnastics because of this
missing functionality. Check
https://stackoverflow.com/questions/31083195/disabling-xdebug-when-running-composer
and xdebug-handler created as a result
https://github.com/composer/xdebug-handler/blob/master/src/XdebugHandler.phpNow, authors of CLI tools ship this xdebug-handler and unload it by default.
This makes their software faster by default, but all the CLI tool authors
must depend on this. And users are less aware of what's going on.If you are a consumer and your CLI tool does not depend on it,
you are out of luck, back to editing .ini files by hand - or
wondering why is the tool slow or even abandoning it because of that.
If you are a consumer and want to debug your CLI tool using it,
you will spend some time figuring out why it doesn't work.I know I went little offtopic here, since this thread is mainly about script
which persists these settings, instead of just CLI switch, but I think this
was worth mentioning, as it complements it. IMO hard to edit ini files are
frustrating mainly because of lacking quick way for disabling extensions.
Having a CLI swith do not only ENABLE extension, but also DISABLE it, would
help a lot and shipping script for modifying ini files might be a lot smaller
necessity after that.