highperapp/highper-php

High-performance asynchronous PHP micro framework targeting C10M concurrency with maximum simplicity and peak performance

dev-main / 1.0.x-dev 2025-06-28 20:34 UTC

This package is auto-updated.

Last update: 2025-06-28 20:35:16 UTC


README

High-performance asynchronous PHP micro framework targeting C10M concurrency with maximum simplicity and peak performance.

🚀 Features

  • C10M Concurrency: Handle 10 million concurrent connections efficiently
  • Interface-Driven Architecture: Pure interface implementations, NO abstract classes, NO final keywords
  • External Foundation Packages: Uses highperapp/di-container and highperapp/router as foundation dependencies
  • Rust FFI Integration: Optional high-performance Rust components for critical path operations
  • Package Auto-Discovery: Automatic integration of HighPer ecosystem packages
  • Async Everything: Built on AMPHP v3 and RevoltPHP for non-blocking operations

🏗️ Architecture

Core Design Principles

  1. Interface-Driven: All contracts defined as interfaces (NO abstract classes)
  2. External Dependencies: Foundation components as external packages
  3. Service Providers: Package integration via auto-discovery
  4. Extension-Friendly: Everything extendable (NO final keywords)
  5. 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/di-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 19+ standalone packages that can be used independently:

Foundation Packages (Required):

  • highperapp/di-container: PSR-11 container optimized for C10M
  • highperapp/router: Ultra-fast router with O(1) lookups + Rust FFI

High-Performance Packages (Optional):

  • highperapp/crypto: Cryptographic operations with Rust FFI
  • highperapp/paseto: PASETO v4 tokens with Rust FFI
  • highperapp/validator: Data validation with Rust FFI
  • highperapp/websockets: WebSocket streaming with backpressure
  • highperapp/database: Async database with EventSourcing/CQRS
  • highperapp/cache: Multi-driver async caching
  • And 10+ more specialized packages...

🦀 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

🔧 Requirements

  • PHP: 8.2+ (8.3+ recommended)
  • Extensions: FFI (optional, for Rust components), OPcache, pcntl, posix
  • Memory: 512MB+ recommended for high concurrency
  • OS: Linux (recommended), macOS, Windows

📝 License

MIT License. See LICENSE file for details.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Built with ❤️ for C10M performance and maximum simplicity from Hyderabad, India.