highperapp/highper-php
最新稳定版本:1.0.4
Composer 安装命令:
composer require highperapp/highper-php
包简介
High-performance asynchronous PHP micro framework targeting C10M concurrency with maximum simplicity and peak performance
关键字:
README 文档
README
Enterprise PHP framework designed for high-scale production applications.
🚀 Quick Start
# Basic server bin/highper serve # Production with all optimizations bin/highper serve --workers=4 --c10m --rust=enabled --memory-limit=1G --zero-downtime # Dedicated ports mode bin/highper serve --mode=dedicated --http-port=8080 --ws-port=8081
🏗️ Hybrid Multi-Process + Async Architecture
Core Design: Combines process isolation with async I/O efficiency
- Multi-process worker spawning using
pcntl_fork() - RevoltPHP + UV hybrid event loop per worker
- Zero-downtime deployments with blue-green/rolling strategies
- C10M optimizations for 10 million concurrent connections
- Rust FFI integration for performance-critical components
Advanced CLI Features
bin/highper help # Show all architecture options bin/highper status # System capability check # Architecture options --workers=COUNT # Worker processes (auto-detect CPU cores) --mode=single|dedicated # Single port vs dedicated ports --c10m # C10M optimizations --rust=enabled # Rust FFI performance boost --zero-downtime # Zero-downtime deployments --deployment-strategy=blue_green # Deployment strategy --memory-limit=SIZE # Worker memory limit
🏗️ Architecture
Core Design Principles
- Interface-Driven: All contracts defined as interfaces (NO abstract classes)
- External Dependencies: Foundation components as external packages
- Service Providers: Package integration via auto-discovery
- Extension-Friendly: Everything extendable (NO final keywords)
- Rust FFI Enhancement: Strategic performance boosts where needed
Foundation Components
Foundation Dependencies:
├── RevoltPHP/EventLoop # Event loop foundation (C10M optimized)
├── AMPHP v3 ecosystem # Async/parallel infrastructure
├── amphp/http-server # HTTP server foundation (C10M ready)
├── amphp/parallel # Multi-process support (scalability)
├── highperapp/container # External PSR-11 container
├── highperapp/router # External ultra-fast router (O(1) lookups)
├── vlucas/phpdotenv # Environment configuration
└── filp/whoops # Error & exception handling
📦 Package Ecosystem
HighPer Framework supports 20+ standalone packages that can be used independently:
Foundation Packages (Required):
highperapp/container: PSR-11 container optimized for C10Mhighperapp/router: Ultra-fast router with O(1) lookups + Rust FFIhighperapp/zero-downtime: Zero-downtime deployment system
Optional Standalone Libraries:
highperapp/cache: Multi-driver async caching with Redis/Memcachedhighperapp/cli: Command-line interface frameworkhighperapp/crypto: Cryptographic operations with Rust FFIhighperapp/database: Async database with EventSourcing/CQRShighperapp/grpc: gRPC server integrationhighperapp/monitoring: Performance monitoring and metricshighperapp/paseto: PASETO v4 tokens with Rust FFIhighperapp/realtime: Real-time communication protocolshighperapp/security: Security enhancements and validationhighperapp/spreadsheet: High-performance spreadsheet manipulationhighperapp/stream-processing: Stream processing capabilitieshighperapp/tcp: TCP server and client implementationshighperapp/tracing: Distributed tracing and observabilityhighperapp/validator: Data validation with Rust FFIhighperapp/websockets: WebSocket streaming with backpressure
🦀 Rust FFI Integration
Strategic Rust components provide massive performance gains:
- Router: 10-50x improvement (O(1) radix tree vs PHP regex)
- Crypto: 5-20x improvement (native operations vs PHP)
- PASETO: 3-10x improvement (vs PHP JWT libraries)
- Validator: 2-5x improvement (native regex + validation)
📁 Project Structure
/home/user/highperapp/
├── src/
│ ├── Contracts/ # Framework interfaces (no abstract classes)
│ │ ├── ApplicationInterface.php
│ │ ├── ContainerInterface.php
│ │ ├── RouterInterface.php
│ │ ├── ConfigManagerInterface.php
│ │ └── ...
│ ├── Foundation/ # Core implementations
│ │ ├── Application.php # implements ApplicationInterface
│ │ ├── ConfigManager.php # implements ConfigManagerInterface
│ │ ├── AsyncLogger.php # implements LoggerInterface
│ │ └── ...
│ ├── ServiceProvider/ # Service provider system
│ │ ├── PackageDiscovery.php # Auto-discover packages
│ │ └── ...
│ └── ...
├── composer.json # Foundation dependencies
└── README.md
🚀 Quick Start
Installation
composer require highperapp/highper-php
Basic Usage
<?php use HighPerApp\HighPer\Foundation\Application; // Create application with auto-discovery $app = new Application([ 'packages' => [ 'auto_discover' => true, # Automatically load installed packages 'websockets' => true, # Enable WebSocket support 'database' => true, # Enable async database 'cache' => true, # Enable high-performance caching ] ]); // Bootstrap and run $app->bootstrap(); $app->run();
With Rust FFI Performance
# Build Rust components for maximum performance cd packages/highper-router/rust && ./build.sh cd packages/highper-crypto/rust && ./build.sh cd packages/highper-paseto/rust && ./build.sh cd packages/highper-validator/rust && ./build.sh
🧪 Comprehensive Testing
Professional test suite covering all architecture components:
# Run all tests php run-tests.php # Specific test suites php run-tests.php --suite=unit # Core components php run-tests.php --suite=integration # CLI and architecture php run-tests.php --suite=performance # C10M validation php run-tests.php --suite=concurrency # Multi-process safety # System capability check php run-tests.php --system-check
Test Coverage
- Unit Tests: ProcessManager, HybridEventLoop, ArchitectureValidator
- Integration Tests: CLI commands, multi-process architecture
- Performance Tests: C10M optimizations, memory efficiency
- Concurrency Tests: Thread safety, race condition prevention
📁 Key Implementation Files
src/Foundation/
├── ProcessManager.php # Multi-process worker management
├── HybridEventLoop.php # RevoltPHP + UV event loop
├── ArchitectureValidator.php # Configuration validation
└── Application.php # Main application bootstrap
tests/
├── Unit/ # Component unit tests
│ ├── ProcessManagerTest.php
│ ├── HybridEventLoopTest.php
│ └── ArchitectureValidatorTest.php
├── Integration/ # Integration tests
│ ├── MultiProcessArchitectureTest.php
│ └── CLIArchitectureTest.php
├── Performance/ # Performance validation
│ └── C10MArchitectureTest.php
└── Concurrency/ # Concurrency safety
└── MultiProcessConcurrencyTest.php
🔧 Requirements
- PHP: 8.3+ with pcntl, posix extensions
- Extensions:
- Required: pcntl, posix (for multi-process architecture)
- Recommended: ext-uv (15-25% performance boost), opcache, FFI (for Rust acceleration)
- Memory: 256MB+ per worker
- OS: Linux (recommended), macOS, Windows
Installing php-uv Extension (Recommended)
For optimal performance in high-concurrency scenarios, install the php-uv extension:
# Ubuntu/Debian sudo apt-get install libuv1-dev sudo pecl install uv # CentOS/RHEL sudo yum install libuv-devel sudo pecl install uv # macOS brew install libuv sudo pecl install uv # Add to php.ini echo "extension=uv" >> /etc/php/8.3/cli/php.ini
Performance Benefits with php-uv:
- 15-25% performance boost in high-concurrency scenarios
- 20-30% memory reduction in event loop operations
- Improved I/O performance for file operations and network connections
- Better timer precision and efficiency
📝 License
MIT License. See LICENSE file for details.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Built with ❤️ for C10M performance and maximum simplicity from Hyderabad, India.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-28