Enterprise PHP Micro-Framework v2.2 β Production-ready features built-in. No config bloat. Just PHP.
| Feature | Description |
|---|---|
| ποΈ Query Builder | DB::table('users')->where('active',1)->paginate(20) β fluent builder on PDO with prepared statements |
| β Guard::check() | Soft auth check β returns bool instead of throwing, perfect for optional-auth endpoints |
| π·οΈ Cache::namespace() | Isolate cache key spaces between modules β Cache::namespace('shop')->get('products') |
| π§ͺ Testing: seed() | $this->seed(['users' => [...]]) β seed test data within transaction rollback |
| β© Pipeline::after() | Post-response hooks for async side effects like audit logging |
| π« #[SkipMiddleware] | #[SkipMiddleware(CorsMiddleware::class)] β exclude routes from global middleware |
| π LogMiddleware | Built-in request/response logging middleware |
| π ErrorHandler::reporter() | ErrorHandler::reporter(callable) β hook for Sentry/Bugsnag integration |
| # | Feature | Description |
|---|---|---|
| 1 | β‘οΈ Middleware Pipeline | #[Middleware('auth', 'rate:10,60')] declarative middleware with Chain of Responsibility |
| 2 | ποΈ DB Migrations | Versioned, batch-rollback migrations with migrate, migrate:rollback, migrate:status |
| 3 | π§ͺ Testing Framework | GeneticTestCase with HTTP client, actingAsAdmin(), assertOk(), assertPaginated() |
| 4 | π Caching Layer | File-based Cache::remember(), tag-based flush, zero dependencies |
| 5 | π Field Selector | ?fields=id,name,price sparse fieldsets β GraphQL-lite without the server |
| 6 | π‘ Genetic Pulse | Server-Sent Events real-time push β no WebSocket server needed |
| 7 | π§© Genetic Modules | GeneticModule plugin system with auto-discovery and lifecycle hooks |
| 8 | π οΈ Admin Generator | make:admin <table> β full CRUD admin endpoint from DB schema in seconds |
| 9 | π€ Endpoint AI | make:endpoint-ai products "CRUD with auth and cache" β NLP scaffold |
| 10 | πͺ Marketplace | market:install og/notifications β community packages in one command |
Plus all v1.0 features: JWT Auth, RBAC, i18n, Audit Trail, Dual SDK, File-based Routing, CLI, OpenAPI
# 1. Clone or create project
composer create-project open-genetics/framework my-api && cd my-api
# 2. Configure environment
cp .env.example .env
# Edit: DB_NAME, DB_USER, DB_PASS, JWT_SECRET
# 3. Bootstrap (tables + RBAC + admin user)
php genetics mutate
# 4. Start dev server
php genetics serve
# β http://127.0.0.1:8080Default admin: [email protected] / password (change immediately in production)
Drop a file in api/ β it's instantly a route. No registration needed.
// api/products.php β GET/POST /api/products
use OpenGenetics\Core\{Response, Cache};
use OpenGenetics\Core\DB;
#[\OpenGenetics\Core\Middleware('auth', 'rate:60,60')]
class Products
{
public static function get(array $body): void
{
// Query Builder with caching
$products = Cache::remember('products:all', 300, fn() =>
DB::table('products')->where('active', 1)->paginate(20)
);
Response::success($products);
}
public static function post(array $body): void
{
// AI-assisted scaffold: php genetics make:endpoint-ai products "with auth and audit"
Response::success(null, 'Created', 201);
}
}Or scaffold in seconds:
php genetics make:endpoint-ai products "CRUD with auth, search, pagination and cache"Database: mutate, seed, status, serve
Migrations: migrate, migrate:rollback, migrate:status
Scaffold: make:endpoint, make:middleware, make:migration,
make:test, make:admin, make:endpoint-ai
Cache: cache:clear, cache:stats, cache:gc
Marketplace: market:list, market:search, market:install
Modules: modules:list
Docs: docs:generate
Info: help, --version, new
my-api/
βββ api/ # File-based routing (1 file = 1 endpoint)
β βββ auth/ # Auth routes (login, register, logout)
βββ src/Core/ # Framework core (PSR-4, PHP 8.1+)
β βββ QueryBuilder.php # Fluent Query Builder (v2.2)
β βββ Cache.php # Caching layer with namespace support (v2.2)
β βββ FieldSelector.php # GraphQL-lite sparse fieldsets
β βββ Pulse.php # Server-Sent Events
β βββ ModuleLoader.php # Plugin system
β βββ AdminGenerator.php # Admin endpoint scaffolder
β βββ EndpointAI.php # AI endpoint generator
β βββ Marketplace.php # Package registry
β βββ Pipeline.php # Middleware pipeline with Pipeline::after()
β βββ Migrator.php # DB migrations
β βββ Database.php # PDO Singleton
β βββ Router.php # File-based router
β βββ Response.php # JSON response helpers
βββ src/Auth/ # JWT + Guard RBAC (Guard::check() v2.2)
βββ src/Testing/ # GeneticTestCase + TestResponse + seed()
βββ src/Middleware/ # Auth, CORS, RateLimit, LogMiddleware
βββ database/migrations/ # Versioned migration files
βββ modules/ # Genetic Modules (plugins)
βββ storage/cache/ # File cache store
βββ sdk/ # Frontend SDK (React + Vanilla JS)
βββ locales/ # i18n dictionaries (en.json, th.json)
βββ genetics # CLI tool
βββ public/ # Web root (index.php)
βββ .env # Environment config
$users = DB::table('users')
->select(['id', 'email', 'role_name'])
->where('is_active', 1)
->where('tenant_id', $tenantId)
->orderBy('created_at', 'DESC')
->paginate(20);#[Middleware('auth:ADMIN', 'rate:10,60')]
class AdminProducts { ... }if (Guard::check()) {
$user = Guard::user(); // personalized response
} else {
// public response
}php genetics migrate # Run pending
php genetics migrate:rollback # Undo last batch
php genetics make:migration add_image_to_productsclass ProductsTest extends GeneticTestCase {
public function testList(): void {
$this->actingAsAdmin();
$this->seed(['products' => [['name' => 'Test', 'active' => 1]]]);
$this->get('/api/products')->assertOk()->assertPaginated();
}
}GET /api/products?fields=id,name,price,category.name
Pulse::broadcast('orders', ['id' => 123, 'status' => 'new']);
// Client: const es = new EventSource('/api/events');php genetics market:search notifications
php genetics market:install og/notificationsFull documentation: open docs/site/overview.html or browse the 26-page docs site.
# Regenerate docs
cd docs/_tools && python3 _gen_pages.pyReport vulnerabilities to [email protected] β do not use the issue tracker.
MIT License β free and open-source. See LICENSE.