arraypress/wp-server-utils
Composer 安装命令:
composer require arraypress/wp-server-utils
包简介
A lean WordPress library for server environment detection and basic system information
关键字:
README 文档
README
A lightweight WordPress library focused on server environment detection and basic system information for plugin developers. Complements WordPress core functions without duplication.
Features
- 🖥️ Server Detection: Apache, Nginx, LiteSpeed, IIS identification
- 🔍 Environment Detection: Localhost, staging, production detection
- 🏢 Hosting Platform Detection: WP Engine, Kinsta, SiteGround, etc.
- 📊 PHP Information: Version, extensions, memory, configuration checks
- 💻 System Basics: OS detection, disk space, load averages
- 🎯 Plugin-Focused: Essential functionality plugin developers need
Requirements
- PHP 7.4 or later
- WordPress 5.0 or later
Installation
composer require arraypress/wp-server-utils
Usage
Server Detection
use ArrayPress\ServerUtils\Server; // Check server type if ( Server::is_apache() ) { // Apache-specific code } if ( Server::is_nginx() ) { // Nginx-specific code } // Get server info $info = Server::get_info(); // Returns: ['type' => 'Apache', 'software' => 'Apache/2.4.41'] // Check capabilities if ( Server::supports_htaccess() ) { // Can use .htaccess files } if ( Server::has_mod_rewrite() ) { // mod_rewrite available }
Environment Detection
use ArrayPress\ServerUtils\Environment; // Environment checks if ( Environment::is_localhost() ) { // Local development } if ( Environment::is_staging() ) { // Staging environment } if ( Environment::is_production() ) { // Production environment } // Get environment type $env = Environment::get_type(); // 'localhost', 'staging', 'production' // Hosting platform detection $platform = Environment::get_hosting_platform(); // 'WP Engine', 'Kinsta', etc. // Container detection if ( Environment::is_docker() ) { // Running in Docker }
PHP Configuration
use ArrayPress\ServerUtils\PHP; // Version checks if ( PHP::meets_version_requirement( '8.0' ) ) { // PHP 8.0+ } // Extension checks if ( PHP::has_extension( 'curl' ) ) { // cURL available } // Memory checks if ( PHP::has_sufficient_memory( '256M' ) ) { // Enough memory } // Get values $memory_limit = PHP::get_memory_limit(); $max_execution = PHP::get_max_execution_time(); $upload_max = PHP::get_upload_max_filesize(); // Function availability if ( PHP::has_function( 'exec' ) ) { // exec() available and not disabled } // Use WordPress core functions for size conversion $bytes = wp_convert_hr_to_bytes( '256M' ); // WordPress core $readable = size_format( 268435456 ); // WordPress core
System Information
use ArrayPress\ServerUtils\System; // OS detection if ( System::is_linux() ) { // Linux-specific code } if ( System::is_windows() ) { // Windows-specific code } // Disk space $disk = System::get_disk_space(); // Returns: ['total' => ..., 'free' => ..., 'used' => ..., 'percent' => ...] if ( System::has_sufficient_disk_space( '1G' ) ) { // At least 1GB available } // System load (Unix systems) $load = System::get_load_average(); // [1min, 5min, 15min] if ( System::is_high_load( 2.0 ) ) { // Load above 2.0 }
What This Library Provides vs WordPress Core
WordPress Core Has:
is_ssl()- SSL detectionwp_get_server_protocol()- HTTP protocolwp_is_mobile()- Mobile detectionwp_is_json_request()- JSON request detectionwp_convert_hr_to_bytes()- Size string to bytes conversionsize_format()- Bytes to human readable conversion
This Library Adds:
- Server type detection (Apache, Nginx, etc.)
- Environment detection (localhost, staging, production)
- Hosting platform identification
- PHP requirement validation
- Basic system information
Key Features
- Lean & Focused: Only essential server detection functionality
- Plugin-Oriented: Built for plugin developers' common needs
- WordPress Compatible: Works alongside core functions
- Environment Aware: Different behaviors for different environments
- Zero Bloat: No unnecessary features or complex monitoring
Requirements
- PHP 7.4+
- WordPress 5.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GPL-2.0-or-later License.
Support
arraypress/wp-server-utils 适用场景与选型建议
arraypress/wp-server-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「wordpress」 「server」 「detection」 「system」 「environment」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 arraypress/wp-server-utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arraypress/wp-server-utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 arraypress/wp-server-utils 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
A jQuery augmented PHP library for creating and validating HTML forms
annotations-scan-plugin
ServerPilot: the best way to run PHP websites.
PSR-15 middleware to handle CSRF-token verification
OAuth Server for CakePHP 3 using the PHP League's OAuth2 Server
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-09-02