PHP Classes

How to show a better phpinfo page using the package Better PHPinfo: Get information about the current PHP request

Recommend this page to a friend!
  Info   Example   Demos   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-11-29 (13 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
betterphpinfo 1.0MIT/X Consortium ...5PHP 5, System information, Debug, Tools
Description 

Author

This package can get information about the current PHP request.

It provides a class that can get several details about the current request that PHP is processing in a similar way to the phpinfo() PHP function.

The class can display the information in a responsive Web page using Bootstrap 5 for styling with dark and light theme support.

The information can be displayed in groups by category using collapsible lists with icons and item counts.

There is a clear separation of the values of the main PHP configuration and the local configuration changes.

It also allows users to search for information entries of the current request using the given search keywords.

The class can also retrieve the current information requests in an array and functions to search for specific information values.

The access to the page where the current request information is displayed can be optionally protected using authentication based on a username and password.

Picture of Thomas Trautner
  Performance   Level  
Name: Thomas Trautner <contact>
Classes: 3 packages by
Country: Germany Germany
Age: 47
All time rank: Not yet ranked
Week rank: Not yet ranked
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Instructions

Example

<?php
/**
 * Example: Standalone PHP Info Display with Authentication
 *
 * This example shows how to use the BetterPhpInfo class with
 * username and password protection. Users must authenticate
 * before seeing the PHP information.
 *
 * Configure your desired username and password below.
 */

// Include the BetterPhpInfo class
require_once 'BetterPhpInfo.php';

// Configure authentication credentials
$requiredUsername = 'admin';
$requiredPassword = 'secure123';

// Create instance and render with authentication
$betterPhpInfo = new BetterPhpInfo();
$betterPhpInfo->render($requiredUsername, $requiredPassword);
?>


Details

BetterPhpInfo - Enhanced PHP Information Display

Version: 1.0 Author: Thomas Traunter | PHPLABOR | www.phplabor.de License: MIT License Description: A modern, visually appealing alternative to phpinfo() with search

         functionality and improved organization using Bootstrap 5.

OVERVIEW

BetterPhpInfo is a PHP class that provides three main ways to access PHP configuration information:

  1. render() - Complete HTML standalone page with Bootstrap UI
  2. search() - Filter results and return as array
  3. get() - Get specific configuration value directly

INSTALLATION

  1. Include the main class file in your project: require_once 'BetterPhpInfo.php';
  2. Create an instance: $betterPhpInfo = new BetterPhpInfo();
  3. Use any of the three methods as needed.

USAGE METHODS

Method 1: Standalone Page (render)

Basic usage (no authentication):

$betterPhpInfo = new BetterPhpInfo();
$betterPhpInfo->render();

With authentication:

$betterPhpInfo = new BetterPhpInfo();
$betterPhpInfo->render('your_username', 'your_password');

Parameters: - username (optional): Required username for access - password (optional): Required password for access

Security: If authentication fails, the login form is shown again without any error messages (for security reasons).

Method 2: Search Configuration (search)

Search for specific settings:

$results = $betterPhpInfo->search('memory');
$results = $betterPhpInfo->search('mysql');
$results = $betterPhpInfo->search('upload');

Returns: Array with matching configuration values organized by category.

Example result structure:

Array(
    [Category Name] => Array(
        [config_key] => Array(
            [local] => 'value',
            [master] => 'master_value'
        )
    )
)

Method 3: Get Specific Value (get)

Get individual configuration values using the exact key names:

$memoryLimit = $betterPhpInfo->get('memory_limit');
$phpVersion = $betterPhpInfo->get('PHP Version');
$uploadMax = $betterPhpInfo->get('upload_max_filesize');

Note: Key names may vary by PHP version. Use search() first to find exact names.

Returns: The local (currently active) value of the configuration setting, or null if not found.

Method 4: Get All Available Keys

Get list of all available configuration keys:

$allKeys = $betterPhpInfo->getAvailableKeys();

Returns: Array of all configuration keys that can be used with get() method.

FINDING AND USING CONFIGURATION VALUES

How to work with configuration values:

  1. FIND THE CORRECT KEY NAME: Use search() to find the exact key name you need:

    $results = $betterPhpInfo->search('memory');

    This will show all keys containing 'memory' with their exact names.

  2. GET THE VALUE: Use the exact key name from search results:

    $value = $betterPhpInfo->get('memory_limit');

    Key names vary by PHP version and configuration - always search first.

MASTER VS LOCAL VALUES: - MASTER: Original value from php.ini configuration file - LOCAL: Currently active value (may be changed at runtime)

When values differ: - The setting was modified using ini_set(), .htaccess, or scripts - get() always returns the LOCAL value (what's currently active) - search() shows both values when they differ

Example: - php.ini has: memory_limit = 128M (Master) - Script runs: ini_set('memory_limit', '256M'); (changes Local) - Result: Master = 128M, Local = 256M - get('memory_limit') returns '256M' (the active value)

FEATURES

Standalone Page Features: - Modern Bootstrap 5 responsive design - Live search with highlighting - Collapsible categories with icons - Statistics overview - Clean formatting of boolean values (enabled/disabled) - 50/50 column layout for better readability - Optional username/password authentication

Search Features: - Case-insensitive search - Searches both keys and values - Returns organized results by category - Preserves all configuration data structure

Get Features: - Direct access to any configuration value - Accepts exact key names as shown in search results - Fast lookup by key name - Returns null for non-existent keys - Returns local (currently active) values

AVAILABLE EXAMPLES

  1. example_standalone_no_login.php - Simple standalone page without authentication - Perfect for development environments
  2. example_standalone_with_login.php - Standalone page with username/password protection - Configure credentials in the file - Secure login without error messages
  3. example_search.php - Demonstrates search functionality with console output - Simple formatted text output - Shows multiple search examples
  4. example_get.php - Shows how to get specific values with console output - Lists common configuration keys organized by category - Simple formatted text output

QUICK START FOR STANDALONE USAGE

For a simple standalone PHP info page, you can also add this directly at the bottom of the BetterPhpInfo.php class file:

// Uncomment these lines for direct standalone usage:
// $betterPhpInfo = new BetterPhpInfo();
// $betterPhpInfo->render();

Then simply access the BetterPhpInfo.php file in your browser.

AUTHENTICATION DETAILS

Login System: - Optional authentication for render() method - Pass username and password as parameters - Secure form-based authentication - No error messages for failed attempts (security feature) - Session-based (form POST method)

Security Features: - No information disclosure on failed login - Clean login interface - Form-based authentication - No timing attack vulnerabilities

CONFIGURATION KEY REFERENCE

Key names in PHP configuration can vary between versions and setups. Examples of possible variations:

  • "memory_limit" (standard)
  • "PHP Version 8.2.29" (version-specific)
  • "Shared memory model" (with spaces)
  • "opcache.enable" (with dots)

RECOMMENDED WORKFLOW: 1. Use search() to locate configuration: $results = $betterPhpInfo->search('opcache'); 2. Examine results to find exact key name 3. Use exact key with get(): $value = $betterPhpInfo->get('opcache.enable');

This approach works reliably regardless of PHP version or key name variations.

COMMON USE CASES

Development Environment: - Use standalone without authentication for local development - Quick overview of PHP configuration - Search for specific settings during debugging

Production Monitoring: - Use with authentication for production servers - Programmatic access via get() for monitoring scripts - Search functionality for troubleshooting

Integration: - Embed search results in existing applications - Extract specific values for application logic - Monitor critical PHP settings programmatically

REQUIREMENTS

  • PHP 7.4 or higher
  • DOMDocument extension (typically included)
  • Web server for standalone usage
  • Bootstrap 5 (loaded via CDN in examples)

TROUBLESHOOTING

Issue: Blank page when using render() Solution: Check PHP error logs, ensure DOMDocument is available

Issue: Authentication not working Solution: Verify username/password are set correctly, check POST data

Issue: get() returns null for existing setting Solution: Use search() first to find the exact key name, then use that exact name

Issue: Search returns no results Solution: Try broader search terms, search is case-insensitive

BROWSER COMPATIBILITY

Standalone page supports: - Chrome 60+ - Firefox 60+ - Safari 12+ - Edge 79+

Features used: - CSS Grid and Flexbox - Bootstrap 5 components - Modern JavaScript (ES6+)

CUSTOMIZATION

The class can be extended for custom functionality: - Override getIconForCategory() for custom icons - Modify CSS in render() for custom styling - Extend search() for custom filtering logic - Add custom authentication methods

MIT LICENSE

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For questions or improvements, visit: https://www.phplabor.de


  example_get.phpExternal page   example_search.phpExternal page   example_standalone_no_login.phpExternal page   example_standalone_with_login.phpExternal page  

Open in a separate window

Open in a separate window

Open in a separate window

Open in a separate window

Screenshots (3)  
  • betterphpinfo1.png
  • betterphpinfo2.png
  • betterphpinfo3.png
  Files folder image Files (9)  
File Role Description
Plain text file BetterPhpInfo.php Class Class file
Accessible without login Plain text file example_get.php Example Example using get()
Accessible without login Plain text file example_search.php Example Example using search()
Accessible without login Plain text file example_standalone_no_login.php Example Standalone without login
Accessible without login Plain text file example_standalone_with_login.php Example Standalone with login
Accessible without login Plain text file README.txt Doc. Instructions

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 0%
Total:0
This week:0