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

serpapi logo
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi

The latest

View all →
Live Stream: Building a Social Network in PHP in 48 Hours image

Live Stream: Building a Social Network in PHP in 48 Hours

Read article
Health for Laravel: Kubernetes Probes and Prometheus Metrics image

Health for Laravel: Kubernetes Probes and Prometheus Metrics

Read article
Fast Excel 5.x Adds Streaming Imports and Safer Exports image

Fast Excel 5.x Adds Streaming Imports and Safer Exports

Read article
What We Know About Laravel 14 image

What We Know About Laravel 14

Read article
Difflock: Lint Laravel Migrations and Diff Your Schema image

Difflock: Lint Laravel Migrations and Diff Your Schema

Read article
Fresh Package: Laravel Package Skeleton with Testbench, CI, and Boost Integration image

Fresh Package: Laravel Package Skeleton with Testbench, CI, and Boost Integration

Read article