PHP Classes

File: README.txt

Recommend this page to a friend!
  Classes of Thomas Trautner   Better PHPinfo   README.txt   Download  
File: README.txt
Role: Documentation
Content type: text/markdown
Description: Instructions
Class: Better PHPinfo
Get information about the current PHP request
Author: By
Last change:
Date: 1 month ago
Size: 11,755 bytes
 

Contents

Class file image Download

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