PHP code example of quillphp / quill
1. Go to this page and download the library: Download quillphp/quill library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
quillphp / quill example snippets
// routes.php
use Handlers\User\ListUsersAction;
use Handlers\User\CreateUserAction;
/** @var \Quill\App $app */
// Simple closure — zero dependencies
$app->get('/hello', fn() => ['message' => 'hello', 'status' => 'ok']);
// Class-based handler — JIT-friendly, stable param-cache key
$app->get('/users', [ListUsersAction::class, '__invoke']);
$app->post('/users', [CreateUserAction::class, '__invoke']); // auto-validates DTO
mermaid
flowchart TD
A["routes.php"] -->|"$app->get / post / ..."| B["App::boot()"]
B -->|"Router::compile()"| C["Route Manifest JSON"]
B -->|"Validator::register()"| E["DTO Schema JSON"]
C -->|"FFI → quill_router_build()"| RT[(matchit\nradix trie)]
E -->|"FFI → quill_validator_register()"| VL[(ValidatorRegistry)]
B -->|"FFI → quill_server_prebind(port)"| Sock[[Shared Socket fd]]
Sock -.->|"dup(2) per worker"| W1 & W2 & WN
subgraph W1 ["Worker 1 — parent process"]
direction LR
QC1["Quill Core\n(Axum / Tokio)"] <-->|"FFI bridge"| PH1[PHP Poll Loop]
end
subgraph W2 ["Worker 2 — pcntl_fork"]
direction LR
QC2["Quill Core\n(Axum / Tokio)"] <-->|"FFI bridge"| PH2[PHP Poll Loop]
end
subgraph WN ["Worker N — pcntl_fork"]
direction LR
QCN["Quill Core\n(Axum / Tokio)"] <-->|"FFI bridge"| PHN[PHP Poll Loop]
end
bash
# Single worker
php -d ffi.enable=on bin/quill serve
# Multi-worker (recommended for production)
QUILL_WORKERS=4 php -d ffi.enable=on bin/quill serve --port=8080