承接 stechstudio/phpinfo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stechstudio/phpinfo

Composer 安装命令:

composer require stechstudio/phpinfo

包简介

A beautiful, searchable replacement for phpinfo() with a clean programmatic API

README 文档

README

Latest Version on Packagist Total Downloads Software License Tests

A beautiful, searchable replacement for phpinfo(). Query PHP configuration programmatically or browse it in a modern UI with dark mode, instant search, and click-to-copy.

Requirements

  • PHP 8.3+
  • ext-dom

Installation

composer require stechstudio/phpinfo

Quickstart

The simplest way to use this package is the global prettyphpinfo() function — a drop-in replacement for phpinfo():

prettyphpinfo();

That's it. You'll get a pretty, searchable, dark-mode-ready page instead of the default phpinfo() output.

If you're not using a framework with Composer autoloading, you'll need to add require __DIR__ . '/vendor/autoload.php'; first.

phpinfo-screenshot

Just like the native phpinfo(), you can pass INFO_* constants to control which sections are displayed:

// Only show modules (excludes environment variables — useful for security)
prettyphpinfo(INFO_MODULES);

// Only general information
prettyphpinfo(INFO_GENERAL);

// Combine flags
prettyphpinfo(INFO_GENERAL | INFO_MODULES);

You can also use the class-based API directly:

STS\Phpinfo\Info::render();

Interact with phpinfo() configuration

If you're looking to directly inspect and interact with the configuration, capture it first:

use STS\Phpinfo\Info;

$info = Info::capture();

// Or capture a subset
$info = Info::capture(INFO_MODULES);

If you have phpinfo() output that you've saved previously and want to load and parse:

use STS\Phpinfo\Info;

// If you've saved the HTML output from phpinfo()
$info = Info::fromHtml($yourSavedHtmlOutput);

// If you've saved the CLI output from phpinfo()
$info = Info::fromText($yourSavedTextOutput);

// Or if you don't know the format, let the package detect it
$info = Info::detect($yourSavedOutput);

From here you can query base info, modules, and configs:

// Your PHP version
$info->version(); // "8.5.4"

// Check for the presence of a specific module. Name is case-insensitive.
$info->hasModule('redis'); // true

// Check to see if a specific configuration key is present.
$info->hasConfig('ICU version'); // true

// Retrieve the value for a specific configuration key. If there is both
// a local and master value, the local is returned by default.
$info->config('max_file_uploads'); // "20"

// Pass 'master' to get the php.ini default instead of the effective local value.
$info->config('max_file_uploads', 'master'); // "100"
$info->config('BCMath support', 'master'); // null

// Convenience methods for common lookups
$info->os(); // "Linux"
$info->hostname(); // "my-server"

Iterating over data structure

You can iterate over the full data structure to loop over your phpinfo() configuration. All lists (modules(), groups(), configs()) return iterable Items objects with filter(), map(), first(), each(), count(), and more.

// Loop over defined modules
foreach($info->modules() as $module) {
    $module->name(); // "session"
    
    // Configs are grouped the same way phpinfo() groups them by table
    foreach($module->groups() as $group) {
        $group->headings(); // ["Directive", "Local Value", "Master Value"]
        
        foreach($group->configs() as $config) {
            $config->name(); // "session.gc_maxlifetime"
            $config->localValue(); // "1440"
            
            $config->hasMasterValue(); // true
            $config->masterValue(); // "28800"
        }
    }
}

The data structure has four levels:

  1. PhpInfo containing modules()
  2. Modules with name(), containing groups()
  3. Groups containing configs() and optionally headings()
  4. Configs with name(), value()/localValue(), and optionally masterValue()

You can also access configs directly from the Module and PhpInfo levels:

// Flatten grouped configs for a single module
$info->module('session')->configs();

// Flatten ALL configs across all modules
$info->configs();

Modules and Groups

Look up a specific module and inspect it directly:

// Case-insensitive lookup. Returns null if not found.
$module = $info->module('zend opcache');

// Retrieve the name as displayed in phpinfo()
$module->name(); // "Zend OPcache"

// Flatten all configs into one collection
$module->configs()->count(); // 59

// Query a specific config from this module
$module->config('Max keys'); // "16229"
$module->config('opcache.enable_file_override', 'master'); // "Off"

// Access individual groups
$group = $info->module('session')->groups()->first();

Simple example

foreach ($info->modules() as $module) {
    echo '<h2>' . $module->name() . '</h2>';

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

Why not just use ini_get() or extension_loaded()?

PHP configuration is spread across a bunch of different functions, each with a narrow scope:

  • ini_get() returns a single INI value, and only the local (effective) value
  • extension_loaded() tells you if an extension is loaded, but nothing about its configuration
  • get_loaded_extensions() gives you a list of names with no details
  • phpversion() and php_uname() each return one thing

All of these require you to know exactly what you're looking for ahead of time. There's no way to discover what's available, iterate over all configuration, or search across modules.

Even if you combine all of them, there are things they simply can't tell you. The configure command PHP was compiled with, Zend extension details, stream wrappers, registered filters, and various per-extension metadata are only available through phpinfo().

phpinfo() is the only function that gives you everything in one place. The problem is it dumps raw HTML (or plain text in CLI) with no API to work with.

This package parses that complete phpinfo() output and gives you:

  • Iterate over all modules and configs without knowing what's installed
  • Get both local and master values (ini_get() only returns the effective local value)
  • Access phpinfo()-only data like compile options, stream wrappers, and registered filters
  • One consistent API instead of juggling five different functions with different return types

stechstudio/phpinfo 适用场景与选型建议

stechstudio/phpinfo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32.1k 次下载、GitHub Stars 达 87, 最近一次更新时间为 2022 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「configuration」 「phpinfo」 「server-info」 「php-info」 「pretty-phpinfo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 stechstudio/phpinfo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 stechstudio/phpinfo 我们能提供哪些服务?
定制开发 / 二次开发

基于 stechstudio/phpinfo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 32.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 87
  • 点击次数: 20
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 87
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-31