Problem
Shipped examples 000–006 cover CLI, simple CGI, sessions, and multipart upload, but none demonstrate throw / catch / HTTP 500 paths. #195 tracks language lowering; presenters lack a copy-paste web demo like 005-SessionsWeb / 006-FileUploadWeb.
MiniWebApp contact validation (#697) and API errors will eventually use exceptions instead of echo + exit.
Goal
Add examples/007-ThrowsWeb/ with:
example.php — form POST; invalid input throw new Exception(...); caught → friendly HTML; uncaught path documented for phpc serve
phpc.json manifest
README.md with VM curls + gate ladder
- Optional:
./phpc init --profile throwsweb follow-up (separate issue)
Acceptance criteria
./phpc lint examples/007-ThrowsWeb/example.php # green after #195 VM
./phpc run examples/007-ThrowsWeb/example.php
./phpc serve 127.0.0.1:8080 examples/007-ThrowsWeb
curl -sf -X POST -d 'email=bad' http://127.0.0.1:8080/example.php | grep -i invalid
Verification (local / Docker)
./script/ci-fast.sh
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev ./script/ci-fast.sh
No GitHub Actions required.
Dependencies
Links
Implementation hints (batch 120)
Proposed tree
examples/007-ThrowsWeb/
example.php # POST form; caught Exception → HTML; doc uncaught 500 path
phpc.json # { "entry": "example.php", "binary": ".phpc/bin/app" }
README.md # curls + gate ladder
Gate ladder (mirror 005/006)
| Step |
Env / command |
Issue |
| VM lint + run |
./phpc lint / run / serve |
this issue |
| Web smoke |
THROWSWEB_WEB_SMOKE_GATE=1 |
#2093 |
| Init scaffold |
./phpc init --profile throwsweb |
#2092 |
| Init parity |
check-init-throwsweb-parity.sh |
#2086 |
| AOT link |
THROWSWEB_AOT_LINK_GATE=1 |
#2101 |
| AOT execute |
THROWSWEB_AOT_SMOKE_GATE=1 |
#2101 |
| Benchmark row |
BENCH_THROWSWEB=1 rebuild-examples |
#2113 |
| doctor |
./phpc doctor --gates |
#2102 |
Tests to touch
Makefile / CI
make web-smoke — include lint path when dir exists
- Do not default-on ci-local until VM curls stable (same as early 005)
File map (language)
| Need |
Blocker |
throw new Exception(...) |
#195 |
catch (Exception $e) |
#57 + #2084 PHPTs |
$e->getMessage() |
#58 method calls |
Verify on harness:
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev ./script/ci-fast.sh
Problem
Shipped examples 000–006 cover CLI, simple CGI, sessions, and multipart upload, but none demonstrate
throw/catch/ HTTP 500 paths. #195 tracks language lowering; presenters lack a copy-paste web demo like 005-SessionsWeb / 006-FileUploadWeb.MiniWebApp contact validation (#697) and API errors will eventually use exceptions instead of
echo+exit.Goal
Add
examples/007-ThrowsWeb/with:example.php— form POST; invalid inputthrow new Exception(...); caught → friendly HTML; uncaught path documented forphpc servephpc.jsonmanifestREADME.mdwith VM curls + gate ladder./phpc init --profile throwswebfollow-up (separate issue)Acceptance criteria
examples/README.mdrun matrix (VM column; JIT/AOT deferred)test/unit/ExamplesCompileTest.phpdiscovers007when lint greenexamples-web-smoke.shslice opt-in viaTHROWS_WEB_SMOKE_GATE=0default until stableVerification (local / Docker)
./script/ci-fast.sh docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev ./script/ci-fast.shNo GitHub Actions required.
Dependencies
throw+ builtinExceptionVMgetMessage)Links
Implementation hints (batch 120)
Proposed tree
Gate ladder (mirror 005/006)
./phpc lint/run/serveTHROWSWEB_WEB_SMOKE_GATE=1./phpc init --profile throwswebcheck-init-throwsweb-parity.shTHROWSWEB_AOT_LINK_GATE=1THROWSWEB_AOT_SMOKE_GATE=1BENCH_THROWSWEB=1 rebuild-examples./phpc doctor --gatesTests to touch
test/unit/ExamplesCompileTest.php— auto-discover007when lint passes (CI: check-examples-ladder-discovery.php — examples/ dirs ↔ ExamplesCompileTest #1913 pattern)test/unit/ExamplesWebSmokeTest.phporscript/examples-web-smoke.sh— Testing: THROWSWEB_WEB_SMOKE_GATE + examples-web-smoke 007 slice #2093test/aot/ThrowsWebAotExecuteTest.php— Testing: THROWSWEB_AOT_LINK_GATE + THROWSWEB_AOT_SMOKE_GATE (007-ThrowsWeb) #2101Makefile / CI
make web-smoke— include lint path when dir existsFile map (language)
throw new Exception(...)catch (Exception $e)$e->getMessage()Verify on harness:
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev ./script/ci-fast.sh