php / php-src

The PHP Interpreter
https://www.php.net
Other
38.15k stars 7.74k forks source link

Add an optional parameter to phpinfo() for html output in CLI SAPI #10040

Open joanhey opened 1 year ago

joanhey commented 1 year ago

Description

Every time exist more CLI app frameworks: amp, react, workerman, ...

And phpinfo(int $what = INFO_ALL): bool allways return an string output without HTML. Every framework can create an html output, but I think that will be better return the same than in other SAPIs. Now it's hardcoded in the C code the output.

~Please add another parameter $html~

~phpinfo(int $what = INFO_ALL, $html = true): bool~ Or add a option in php.ini, phpinfo.html=false , perhaps it's easier. By default for CLI will be false. But will be changed easily for any CLI framework.

Thank you !!

cmb69 commented 1 year ago

Hmm, that appears to be reasonable. @kelunik, @clue, thoughts?

kelunik commented 1 year ago

I guess it should be another function instead of a boolean parameter? I haven't felt any need for it, yet.

joanhey commented 1 year ago

The problem is that any app or framework, normally use a link to phpinfo() to show the information. So another parameter to phpinfo() or another function don't work, without change the code in the app or fw.

Example: image

kelunik commented 1 year ago

If you use Amp, React, or something similar, you'll want the HTML as string anyway instead of writing to the output buffer. But I've read the docs now, switching to text mode on CLI magically isn't really helpful in that case.

joanhey commented 1 year ago

The image from before is Symfony with Workerman. But also work with Slim, Laravel, Lumen, Yii, CakePHP, KumbiaPHP, ... and the apps using these frameworks.

And for that we need to use the output buffers, to show all the pages. So it is NOT a problem for the phpinfo() too.

joanhey commented 1 year ago

I'll show you a video with Workerman and Symfony. And the problem with phpinfo() now. Of course, we can create a new phpinfo() in Workerman, but why not use the one from PHP.

https://user-images.githubusercontent.com/249085/206700896-7866889b-8c75-4762-b002-b6ac3ec1963f.mp4