Repository navigation
AOT: Project entry require-as-expression bootstrap (config.php → Router) (#764) #783
Description
Problem
examples/003-MiniWebApp/public/index.php bootstraps the app with require-as-expression and a separate class load before dispatch:
$config = require __DIR__ . '/../config.php';
require __DIR__ . '/../src/Router.php';
$router = new Router($config);
$router->dispatch($method, $route);#752 ✅ links the project; #764 tracks empty stdout on native execute. VM/phpc serve prints HTML — the gap is specific to AOT runtime through the compiled entry graph.
This path is distinct from #776 (void render* + template include) and #739 (isolated void+include fixture): if the entry TU mishandles require return values or class constructor wiring, dispatch may run with an empty config or never reach template output.
Goal
Native .phpc/bin/app executes the same bootstrap as VM:
config.phparray return populatesRouter(app_nameneedle in HTML)new Router($config)succeeds under AOT ABI (Language: Typed property array (private array $config) in VM/JIT/AOT #767 typedarrayproperty)
Scope
- AOT lowering for
requireused as expression (return value from included file) - Multi-TU order:
phpc.jsonincludes[]+ entrypublic/index.php(AOT: Honor phpc.json includes array in phpc build --project #452) - Reproduce with minimal fixture if full MiniWebApp is too heavy (extend
test/fixtures/aot/)
Implementation hints
| Area | Files | Notes |
|---|---|---|
| Entry | examples/003-MiniWebApp/public/index.php |
PATH_INFO + ?route= fallback |
| Manifest | examples/003-MiniWebApp/phpc.json |
includes: Router.php, config.php |
| AOT compile | lib/AOT/, lib/Compiler.php |
Compare VM path for require expr |
| Compare | examples/001-SimpleWeb |
flat entry — green reference |
Reproduce (local / Docker)
make docker-build-22
docker run --rm -i -w /compiler php-compiler:22.04-dev bash -lc '
tar -xf - && composer install -q && ./script/apply-patches.sh
php bin/phpc.php build --project examples/003-MiniWebApp
cd examples/003-MiniWebApp
QUERY_STRING=route=home REQUEST_METHOD=GET ./.phpc/bin/app | wc -c
'Expect non-zero bytes; currently 0 (batch 52 harness verify).
Acceptance criteria
- Manual probe above emits HTML containing
MiniWebAppfrom config - Covered by Testing: MiniWebAppAotExecuteTest CLI smoke (#485, #676 step 2) #747
MiniWebAppAotExecuteTestGET home assertion (or dedicated fixture PHPT) - No regression in
PhpcBuildProjectTest::testMiniWebAppBuildLinksNativeBinary
Dependencies
- AOT: MiniWebApp native binary CLI execute emits empty stdout (post-link) #764 — umbrella execute blocker
- Language: Typed property array (private array $config) in VM/JIT/AOT #767 — typed
private array $config - Testing: MiniWebAppAotExecuteTest CLI smoke (#485, #676 step 2) #747 — PHPUnit gate
- AOT: Router render* void methods — template include must emit stdout (#764) #776 — template include tier (may also be required)
Verification
Local/Docker only — ./script/docker-ci-local.sh, make test-docker. Do not require GitHub Actions.
Links
- AOT: MiniWebApp native binary CLI execute emits empty stdout (post-link) #764, AOT: Router render* void methods — template include must emit stdout (#764) #776, AOT: Green method_include_void.phpt and @group aot-link for void+include methods #739, Testing: MiniWebAppAotExecuteTest CLI smoke (#485, #676 step 2) #747
- ROADMAP 🗺️ ROADMAP: Self-host + web-capable PHP subset (living) #78
Activity
Merge pull request #798 from PurHur/fix/aot-require-return-value-783
Merge pull request #855 from PurHur/fix/aot-require-return-hashtable-…