thesis / demo
A small HTTP server with console logging that shows how concurrent requests overlap.
Fund package maintenance!
Requires
- php: ^8.6
- ext-pcntl: *
- thesis/async: dev-main
- thesis/dispatcher: dev-main
- thesis/exceptionally: dev-main
- thesis/formatter: dev-main
- thesis/http: dev-main
- thesis/io: dev-main
- thesis/logger: dev-main
- thesis/net: dev-main
- thesis/source-location: dev-main
- thesis/time: dev-main
Requires (Dev)
- thesis/hot-reload: dev-main
- thesis/process: dev-main
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-26 15:34:11 UTC
README
Thesis Demo
This read-only repository mirrors
packages/demo. Open issues and pull requests in the thesis-php/thesis monorepo.
This small HTTP server shows how requests overlap while a handler waits. Open the
home page for links to the demo routes.
GET /wait/250ms waits for the requested duration and returns Waited for 250ms. With no duration, GET /wait returns Waited for 0s.
GET /error throws an exception so you can see how the server handles a failed request.
Run
Use 64-bit PHP 8.6 with Io\Poll\Context and ext-pcntl on Unix. Once the split is on Packagist, install
the development version with Composer.
composer create-project thesis/demo demo dev-main
cd demo
php app.php
To restart the installed server automatically whenever you save app.php or index.html, start it with
thesis/hot-reload.
vendor/bin/hot-reload --watch app.php --watch index.html -- php app.php
The server listens on all IPv4 interfaces on ports 18080 (HTTP) and 18443 (HTTPS). The demo ships a self-signed localhost certificate and its private key for local development. From the installed project, verify HTTPS on port 18443 with:
curl --cacert tls/localhost.crt https://localhost:18443/wait
From the monorepo root, run make install, then publish both ports on loopback:
docker compose run --rm -p 127.0.0.1:18080:18080 -p 127.0.0.1:18443:18443 php php packages/demo/app.php
To watch the demo in Docker, run this from the same directory:
docker compose run --rm -p 127.0.0.1:18080:18080 -p 127.0.0.1:18443:18443 php \
packages/hot-reload/bin/hot-reload --watch packages/demo/app.php --watch packages/demo/index.html \
-- php packages/demo/app.php
Compare requests
In another terminal, send the same eight requests sequentially and then concurrently.
time curl -fsS 'http://127.0.0.1:18080/wait/25[0-7]ms'
time curl -fsS --parallel --parallel-immediate 'http://127.0.0.1:18080/wait/25[0-7]ms'
On an idle machine, expect about two seconds for the first command and about 250 ms for the second. The console shows the path and duration of each finished request. Press Ctrl+C to stop the server.
The server and logger are wired in app.php.