Req #66260 [Com]: Provide phpinfo() alternative that returns array
Edit report at https://bugs.php.net/bug.php?id=66260&edit=1
ID: 66260
Comment by: me at paulofreitas dot me
Reported by: preinheimer@php.net
Summary: Provide phpinfo() alternative that returns array
Status: Open
Type: Feature/Change Request
Package: Unknown/Other Function
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Yeah, it's PHP 5.6 days and it still a nightmare to get a single info from phpinfo() output.
phpinfo() doc comments have a few tricks to do this, but it's far from ideal. A built-in
function like phpinfo_array() which expose this data in a more meaningful way would be very welcome!
:)
Previous Comments:
------------------------------------------------------------------------
[2013-12-11 02:52:01] preinheimer@php.net
Description:
------------
There's several reasons to want an easily parsed phpinfo() output, chief amongst them to ensure
that a series of servers have the same packages, and are configured in the same manner. There's
a series of solutions[1] built on top of using the output from phpinfo(), then parsing it back into
arrays. Clearly this is sub-optimal.
A userland alternative would be to run through the various functions like ini_get(),
get_loaded_extensions(), etc. But not quite as pretty, I'm not sure if the same level of
information is even exposed there (phpinfo() shows me master, and current, can I get that from
ini_get())?
[1] like http://php.net/phpinfo#84259
Test script:
---------------
$config = phpinfo(-1, TRUE);
echo json_encode($config);
Expected result:
----------------
A beautiful json output of the PHP's server configuration. I'd then be able to use
PHP's glorious array functions to easily compare it to another server's and find problems.
Actual result:
--------------
Hrm, this seems like the kind of question I'd see on a test. phpinfo() will error because
it's not expecting the second parameter, so I'll run with C) error.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66260&edit=1
Thread (3 messages)