getphex / framework
A PHP web framework designed for native ElephC compilation.
Requires
- php: ^8.3
- composer-runtime-api: ^2.2
Requires (Dev)
- ext-pdo: *
- ext-pdo_sqlite: *
- phpunit/phpunit: ^11.5
Suggests
- ext-pdo: Required when using the optional database adapter.
- ext-pdo_sqlite: Required for SQLite applications and the database example.
Provides
None
Conflicts
None
Replaces
None
README
Phex
Run on PHP. Compile with ElephC.
PHP-compatible sources · Native compilation · Immutable HTTP · Typed middleware
A PHP web framework designed first for native compilation with ElephC. Run the same shared sources directly on PHP, with immutable HTTP messages, typed handlers and middleware, and an explicit middleware pipeline.
Overview
Phex is a PHP web framework designed for native compilation with ElephC. Shared application sources run directly on PHP, with explicit dependency injection, immutable HTTP messages, typed middleware and precompilable routing.
Develop on PHP without generating artifacts. Build generated PHP for PHP-FPM, or compile a native HTTP executable. Native application lifecycle can retain application services per worker while each request receives an isolated scope.
Phex is in development. The current checkout includes a portable application skeleton, typed JSON/query input, named URLs, structured logging and an optional PDO module with a persistent SQLite CRUD example.
Documentation
Read the Phex handbook for focused guides, practical examples and a learning path from your first endpoint to PHP/native deployment.
| Start with | Learn how to |
|---|---|
| Installation | Create an application from this checkout |
| Quickstart | Add a typed endpoint, service and named route |
| Lifecycle | Separate application state from request state |
| HTTP guides | Route requests, compose middleware and validate input |
| SQLite CRUD | Persist data through PHP and native HTTP |
| Builds | Choose development, generated PHP or native execution |
| Native servers | Configure workers, application lifetime and startup |
Requirements
- PHP 8.3 or newer within PHP 8.x and Composer 2 for applications.
- A complete ElephC SDK for native compilation; CI targets release 0.27.6 and precompiled release 0.27.7 with application-lifecycle support. The CI downloads official release SDKs and does not build ElephC from source.
- PDO and the selected driver when using the optional database adapter.
- Python 3.10+ and
pdo_sqlitefor framework development checks.
Linux native builds also need the platform's assembler/linker, libc development files and bzip2 development library. See Installation.
Create an application
From a framework checkout, before a versioned package release:
composer install --no-dev
php bin/phex new ../my-app --local
cd ../my-app
composer install
composer serve
Open http://127.0.0.1:8080/ for {"hello":"world"}. Development PHP needs no
build artifacts. --local adds an explicit mirrored Composer path dependency
on this checkout. Continue with the Quickstart.
Build PHP or native output
Inside the created application:
composer build php -S 127.0.0.1:8080 -t public public/compiled.php
For native execution, after stopping the PHP server:
composer build:native ./var/build/start --listen 127.0.0.1:8080 --workers 1
Builds explains regeneration. PHP deployment and Native servers describe runtime configuration and artifacts.
Examples
The framework checkout includes hello-world, routing, request lifetimes, compiled containers and persistent SQLite CRUD. The canonical application template lives in stubs/application and is automatically published to getphex/phex. See Package distribution.
Static analysis
From the framework repository root:
composer install composer tools:install composer analyse
PHPStan runs at maximum level without a baseline or broad suppressions. PHP files follow the required purpose-header template. The contribution guide describes shared-source conventions.
Test both runtimes
composer check
The framework checks generated artifacts, installed HTTP applications and matching
PHP/ElephC behavior cases. Application-capable SDKs can also run
composer test:persistent. See Testing for requirements and
application test examples, or Benchmarking for measurement tools.
License
Phex is licensed under the MIT License. Copyright (c) 2026 Vincenzo Petrucci (Illegal Studio).