I quickly looked through the code for a neat extension, and there is a way to change the configuration of the output buffer handler.
However, this is not very good. It uses a code function, which, obviously, may change in future versions.
The function that processes the buffer processing, php_tidy_output_handler and line 1191 , calls the macro TIDY_SET_DEFAULT_CONFIG .
If tidy.default_config not set, the macro does nothing. If it is installed, the configuration file is read from the disk and the parameters are analyzed.
Since the configuration file is loaded while parsing the output buffer, before parsing can begin, you can modify the configuration file from your PHP script.
This means that you must do tidy.default_config = /file/writable/by/php and dynamically update this file to contain the parameters you need. (I told you this is not very good).
I immediately see a problem with this. There is a potential race condition.
If two scripts require different parameters, and both of them are executed simultaneously, there is a possibility that one of the scripts will get the wrong configuration.
The file is clearly not intended to change ad-hocly - and, as you can probably follow from the extension code, there is no other way to enter configuration parameters, since the parameters are document-specific.
- Created a new TidyDoc.
- A pair of set flags config + default_config loaded.
- The buffer is parsed.
Sorry, it seems that in the end I'm just delivering bad news.
A better solution might be to call the ob_start callback, where you have full control over the parameters of the document.
Edit:
There was a little brainstorming and tried a few things to get around this. Everything was completed with an error.
I tried registering a custom thread wrapper to return script values ββand set tidy.default_config = tidy://config . It turns out that stream wrappers are not allowed by the configuration loader, and this does not work.
One thing that I could not verify correctly is the configuration for each .user.ini directory or [PATH=] ini. They are available only with CGI / FastCGI SAPI (not FPM). I suspect that this probably will not help you either.