Php.ini turning off an extension without commenting it out

I’m trying to turn off an extension in php.ini without commenting it out.

So this would enable it:

zend_extension="/wherever/you/put/it/xdebug.so"

But what would disable it? Maybe just pointing toward a bad path? Not sure if that might cause unexpected errors though.

My situation is that I want to override earlier ini settings with my own php.ini addition. While this is easy with some ini settings that simply take variables or on/off, it seems more tricky with extensions where a path is involved. (Commenting it out won’t work in this situation because it would just ignore my commented out line and use the earlier line that is not commented out.)

so… comment…out… both lines? Why would you have the same extension loaded more than once?

I would be more inclined to have a bare minimum of php.ini features and to add additional items as and when required.

Commenting out both lines is not optimal (should have inferred that from the post…). I am not loading an extension more than once. I want to either load an extension, or just not load it. But my php install includes MULTIPLE ini’s for different situations, with set priorities in a folder for includes. (your typical conf.d-type folder) and I would like to override previous included ini’s with later included ini settings.

Here is what is happening:

ini1
(original php ini, untouched)

ini2:

zend_extension="/wherever/you/put/it/xdebug.so"

ini3:

(something to disable the "  zend_extension="/wherever/you/put/it/xdebug.so" " line)

ini2 is a special static ini meant for a general set of servers. ini3 is meant for very specific servers and inherits the settings of ini2 (and ini1, the original) but I need to disable/turn off the loading of extensions for these servers.

And before it might be suggested, making a specific ini for the smaller server subset that needs ini3 is not optimal. It would require maintaining many more ini’s than my simple example is illustrating, and double checking that they all fit together well.

The only work around so far to stop an extension from being loaded on an earlier line is to point to the extension on a later line to a wrong path, which yields a php error on startup.

Things work nicely as long as a path isn’t involved in an ini setting. Setting a timezone in an earlier ini, and then changing it in a later ini, works as expected.

Personally, I find the idea of telling the PHP server to load an invalid extension (which forces error checking, logging, etc) to be ‘not optimal’, to use your language.

If you’ve got servers that use all of ini1, part of ini2, and part of ini3, what you actually have is
All Common Elements in ini1.
Elements specific to one type of server in ini2
Elements specific to the other type of server in ini3.

No overlap at all. And yes, there are more ini’s to modify - but thats what you get with having multiple server configurations.

To each their own, I suppose.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.