Framework PHP hiện đại có thể chạy song song trên cả RoadRunner và Traditional Web Server (Apache, Nginx, PHP Built-in Server).
- 🚀 Dual Runtime Support: Chạy trên cả RoadRunner và traditional web servers
- ⚡ High Performance: Tận dụng RoadRunner worker pool để tăng hiệu suất
- 🔄 Hot Reload: Tự động reload khi code thay đổi (RoadRunner mode)
- 📊 Metrics: Built-in metrics endpoint
- 🎯 PSR-7 Compatible: Hỗ trợ PSR-7 HTTP messages
- 🛠️ Environment Detection: Tự động detect và tối ưu cho từng môi trường
- PHP >= 8.1
- Composer
- (Optional) RoadRunner binary
composer installcp .env.example .envcomposer rr:download# Development mode với hot reload
composer rr:serve:dev
# Production mode
composer rr:serveTruy cập: http://localhost:8080
composer serveTruy cập: http://localhost:8000
- Point document root đến thư mục
public/ - Đảm bảo
.htaccessđược enable (Apache) hoặc cấu hình nginx rewrite rules - Truy cập qua domain/virtual host của bạn
witals-app/
├── app/ # Application code
│ ├── Application.php # Core application class
│ ├── Contracts/ # Interfaces
│ └── Http/ # HTTP layer
│ ├── Kernel.php # HTTP kernel
│ ├── Request.php # Request wrapper
│ └── Response.php # Response wrapper
├── bootstrap/ # Bootstrap files
│ └── app.php # Application bootstrap
├── public/ # Public directory
│ ├── index.php # Traditional web server entry
│ └── .htaccess # Apache configuration
├── worker.php # RoadRunner worker entry
├── .rr.yaml # RoadRunner configuration
├── .env.example # Environment variables example
└── composer.json # Dependencies
File .rr.yaml chứa cấu hình cho RoadRunner:
- HTTP server settings
- Worker pool configuration
- Hot reload settings
- Metrics endpoint
Cấu hình ứng dụng thông qua file .env:
- App settings
- RoadRunner settings
- Database configuration
- Cache & session settings
GET /- Home page với thông tin hệ thốngGET /health- Health check endpointGET /info- Detailed system information
Framework tự động detect môi trường đang chạy:
if ($app->isRoadRunner()) {
// RoadRunner specific code
} else {
// Traditional web server code
}- Worker pool tái sử dụng PHP processes
- Không cần khởi tạo lại framework mỗi request
- Tốc độ nhanh hơn 5-10 lần so với PHP-FPM
- Phù hợp cho shared hosting
- Dễ dàng debug
- Không cần cài đặt thêm
Khi chạy RoadRunner, metrics có sẵn tại:
http://localhost:2112/metrics
RoadRunner tự động reload khi file .php thay đổi trong thư mục app/ và public/:
reload:
interval: 1s
patterns: [".php"]
services:
http:
dirs: ["app", "public"]Set APP_DEBUG=true trong .env để enable debug mode.
MIT License
Puleeno Nguyen puleeno@gmail.com