Hi, Internals!

I want to have a unified function phpinfo() for any environment.

Currently phpinfo works different in CLI and SAPI modes:
- SAPI mode enforces the function print HTML tags
- CLI mode enforces the function print text as is

Here is implementation of the function:
https://github.com/xepozz/php-src/blob/5dd9b0dcef229c55f67044537b076c6e4320f28c/ext/standard/info.c#L760

So I'd like to create a separate function phpinfo_json() which will dump
pretty much the same text as a json structure.
Use-case as simple as absurd:
- PHP/php -S serves the content as a SAPI mode
- RoadRunner/Queues/Workers which run PHP scripts as `php index.php` run it
as CLI mode

It's not convenient to see CLI-like output when you run a web server.
It's not possible to fetch some info from the function output
User should write parsers for both function variations: SAPI and CLI to
parse something
There is no need to use the output buffers to get the information.

New function output could be an array-like structure or a json string. It's
open to discuss. I'm okay with any or even both with a flag "$asArray"

-- 
Best regards,
Dmitrii Derepko.
@xepozz

Reply via email to