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: PhpInfomodules()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 →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article