highperapp / highper-php
High-performance asynchronous PHP micro framework targeting C10M concurrency with maximum simplicity and peak performance
Requires
- php: ^8.3|^8.4
- amphp/amp: ^3.0
- amphp/http-server: ^3.0
- amphp/parallel: ^2.0
- filp/whoops: ^2.0
- highperapp/compression: ^1.0
- highperapp/container: ^1.0
- highperapp/grpc: dev-main
- highperapp/router: ^1.0
- highperapp/tcp: dev-main
- highperapp/zero-downtime: ^1.0
- psr/container: ^2.0
- psr/log: ^3.0
- revolt/event-loop: ^1.0
- vlucas/phpdotenv: ^5.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: ^3.7
- symfony/var-dumper: ^6.0
Suggests
- ext-ffi: FFI extension for Rust acceleration support
- ext-opcache: OpCache extension for improved performance
- ext-pcntl: Process Control extension for multi-process architecture
- ext-posix: POSIX extension for signal handling
- ext-uv: Install php-uv extension for optimal performance in high-concurrency scenarios (15-25% performance boost)
- highperapp/cache: High-performance caching with Redis/Memcached
- highperapp/compression: High-performance compression with Rust FFI acceleration and Brotli/Gzip support
- highperapp/crypto: High-performance cryptographic operations
- highperapp/database: Async database adapters for MySQL/PostgreSQL
- highperapp/grpc: gRPC server integration
- highperapp/monitoring: Performance monitoring and metrics
- highperapp/paseto: PASETO token authentication
- highperapp/realtime: Real-time communication protocols
- highperapp/security: Security enhancements and validation
- highperapp/tcp: Enterprise TCP server and client with connection pooling
- highperapp/validator: High-speed data validation
- highperapp/websockets: WebSocket streaming with backpressure
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 18+ 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.