Skip to content
mohitky2018Public

About

AeroPHP is a lightweight, high-performance, API-only PHP framework designed for building microservices and high-concurrency applications.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AeroPHP Framework

PHP Version License Swoole

AeroPHP is a lightweight, high-performance, API-only PHP framework designed for building microservices and high-concurrency applications.

Features

  • 🚀 Async I/O - Built on Swoole for non-blocking, coroutine-based execution
  • 📦 PSR Compliant - PSR-4, PSR-7, PSR-11, PSR-15 standards
  • ⚡ Zero Bloat - API-only focus, no sessions, views, or frontend tooling
  • 🔧 DI Container - Pre-compiled container for zero runtime reflection overhead
  • 🛣️ Attribute Routing - Define routes with PHP 8 attributes
  • 🗄️ Async ORM - Connection pooling with SQLite (default), MySQL, and PostgreSQL support
  • 📊 Microservices Ready - Service discovery, health checks, Prometheus metrics
  • 🔄 State Isolation - Request-scoped containers prevent memory leaks

Requirements

  • PHP 8.2+
  • Swoole extension (recommended) or RoadRunner
  • Composer

Installation

composer create-project aerophp/framework my-project
cd my-project
cp .env.example .env

Quick Start

Start the Server

# With Swoole (recommended)
php server.php

# Development mode (PHP built-in server)
php bin/aero serve

Create a Controller

php bin/aero make:controller ProductController

Define Routes with Attributes

<?php

namespace App\Controllers;

use Aero\Routing\Attributes\{Get, Post, Put, Delete};
use Aero\Http\JsonResponse;

final class ProductController extends Controller
{
    #[Get('/api/products')]
    public function index(): JsonResponse
    {
        return JsonResponse::success(Product::all());
    }

    #[Get('/api/products/{id}')]
    public function show(int $id): JsonResponse
    {
        return JsonResponse::success(Product::find($id));
    }

    #[Post('/api/products')]
    public function store(Request $request): JsonResponse
    {
        $product = Product::create($request->json());
        return JsonResponse::created($product);
    }
}

Async Database Operations

// Connection pooling prevents blocking
$users = User::where('active', true)
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->get();

CLI Commands

php bin/aero serve              # Start development server
php bin/aero make:controller    # Generate controller
php bin/aero make:model         # Generate model (with -m for migration)
php bin/aero make:migration     # Generate migration
php bin/aero migrate            # Run migrations
php bin/aero migrate:rollback   # Rollback last batch
php bin/aero migrate:status     # Show migration status
php bin/aero routes:list        # List all routes

Directory Structure

aerophp/
├── app/
│   ├── Controllers/        # HTTP controllers
│   ├── Models/             # Database models
│   ├── Middleware/         # Custom middleware
│   └── Providers/          # Service providers
├── bin/
│   └── aero               # CLI tool
├── config/
│   ├── app.php            # Application config
│   ├── database.php       # Database config
│   └── services.php       # Service discovery config
├── database/
│   └── migrations/        # Database migrations
├── public/
│   └── index.php          # Traditional entry (optional)
├── src/                   # Framework source
├── storage/
│   ├── cache/             # Compiled files
│   └── logs/              # Application logs
├── server.php             # Swoole entry point
└── composer.json

Configuration

Copy .env.example to .env and configure:

APP_NAME=MyAPI
APP_ENV=production
APP_DEBUG=false

SERVER_HOST=0.0.0.0
SERVER_PORT=8080
SERVER_WORKERS=4

# SQLite (default) - Just works out of the box!
DB_CONNECTION=sqlite
DB_DATABASE=./database/database.sqlite

# Or use MySQL
# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_DATABASE=myapp
# DB_USERNAME=root
# DB_PASSWORD=
# DB_POOL_SIZE=64

Microservices

Health Check

GET /health

Prometheus Metrics

GET /metrics

Service Discovery

Configure Consul or Etcd in .env:

SERVICE_DISCOVERY_DRIVER=consul
CONSUL_HOST=127.0.0.1
CONSUL_PORT=8500

Architecture

  • State Pollution Prevention: Request-scoped containers isolate state
  • Pre-compiled DI: Zero reflection overhead in production
  • Connection Pooling: Async database without blocking
  • SOLID Principles: Interface-driven, swappable components

License

MIT License

About

AeroPHP is a lightweight, high-performance, API-only PHP framework designed for building microservices and high-concurrency applications.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages