Laravel Packages

Pretty PHP Info: A Modern Replacement for `phpinfo()`

Published

Pretty PHP Info is a package by Joseph Szobody of Signature Tech Studio that replaces the default phpinfo() output with a modern, searchable UI — and adds a PHP API for querying your PHP configuration programmatically.

The simplest way to use it is the prettyphpinfo() drop-in function:

prettyphpinfo();

That swaps out the default output for a dark-mode-ready page with instant search and click-to-copy values. You can pass the same INFO_* constants as phpinfo() to filter which sections are shown:

// Only show modules (useful for hiding environment variables)
prettyphpinfo(INFO_MODULES);
 
// Combine flags
prettyphpinfo(INFO_GENERAL | INFO_MODULES);

Querying PHP Configuration Programmatically

Beyond the UI, the package gives you an API to inspect your PHP configuration in code. Capture the output with Info::capture() and then query it:

use STS\Phpinfo\Info;
 
$info = Info::capture();
 
$info->version(); // "8.4.19"
$info->hasModule('mysqli'); // true
$info->config('post_max_size'); // "32M" (local/effective value)
$info->config('post_max_size', 'master'); // "2M" (php.ini default)
$info->os(); // "Linux"
$info->hostname(); // "my-server"

One notable capability is fetching both the local (effective) value and the master (php.ini default) for any directive — something ini_get() alone can't do.

Why Not Just Use ini_get()?

PHP scatters its configuration across several functions — ini_get(), extension_loaded(), get_loaded_extensions(), phpversion() — and each one only tells you one specific thing. None of them let you discover what's available, iterate over all configuration, or see phpinfo()-only data like compile options, stream wrappers, and registered filters.

phpinfo() is the only function that gives you everything in one place, but it outputs raw HTML or plain text with no API to work with. This package parses that output and exposes it through a consistent interface.

Iterating Over Configuration

You can also walk the full configuration structure. Modules, groups, and configs are returned as iterable Items collections with filter(), map(), first(), each(), and count():

foreach ($info->modules() as $module) {
echo '<h2>' . $module->name() . '</h2>';
 
foreach ($module->configs() as $config) {
echo $config->name() . ': ' . $config->value();
if ($config->hasMasterValue()) {
echo ' (master: ' . $config->masterValue() . ')';
}
}
}

The data structure mirrors how phpinfo() organizes things: PhpInfo → modules() → groups() → configs(). You can also flatten and access configs directly from any level.

You can load previously saved phpinfo() output as well:

$info = Info::fromHtml($savedHtmlOutput);
$info = Info::fromText($savedTextOutput);
$info = Info::detect($savedOutput); // auto-detects format

Installation

Requires PHP 8.3+ and ext-dom.

composer require stechstudio/phpinfo

You can view the source code for the package on GitHub or learn more on the official website at prettyphpinfo.com.

Yannick Lyn Fatt photo

Staff Writer at Laravel News and Full stack web developer.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
PHP News: A New Site for PHP Releases, RFCs, and Packages image

PHP News: A New Site for PHP Releases, RFCs, and Packages

Read article
Pause Polling in Background Tabs in Inertia.js v3.9 image

Pause Polling in Background Tabs in Inertia.js v3.9

Read article
Look What You Helped Me Build image

Look What You Helped Me Build

Read article
BashBox: A Sandboxed Bash Interpreter for AI Agents in PHP image

BashBox: A Sandboxed Bash Interpreter for AI Agents in PHP

Read article
Running Laravel's Scheduler on Multiple Servers image

Running Laravel's Scheduler on Multiple Servers

Read article
Laravel Fake Assertions Now Accept Property Arrays image

Laravel Fake Assertions Now Accept Property Arrays

Read article