Req #66260 [Opn->Csd]: Provide phpinfo() alternative that returns array

From: Date: Fri, 29 May 2015 08:54:32 +0000
Subject: Req #66260 [Opn->Csd]: Provide phpinfo() alternative that returns array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192996@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66260&edit=1

 ID:                 66260
 Updated by:         kalle@php.net
 Reported by:        preinheimer@php.net
 Summary:            Provide phpinfo() alternative that returns array
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Unknown/Other Function
 Operating System:   All
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        kalle
 Block user comment: N
 Private report:     N

 New Comment:

While this internally is not a trival task, it is just a little time consuming.

This is because the PHP_MINFO hook for each extension can choose to write their "style"
for each block in the phpinfo() output. Personally I don't see this happening in 7.0, mainly
due to extension structure changes it would require.

Sadly this needs to be done in userland PHP code for the next long time, I think its better to go
for an RFC when the next major version is coming out for a richer discussion about this.


Previous Comments:
------------------------------------------------------------------------
[2014-05-28 14:21:56] me at paulofreitas dot me

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!
:)

------------------------------------------------------------------------
[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)

« previous php.bugs (#192996) next »