Problem
PHP apps and frameworks use $_SERVER['DOCUMENT_ROOT'] to resolve includes, templates, and static asset paths. The compiler dev server serves static files from a docroot (#150 closed) but does not expose DOCUMENT_ROOT in $_SERVER, so scripts cannot build paths like:
require $_SERVER['DOCUMENT_ROOT'] . '/config.php';
This blocks #54 include paths, #194 fopen templates, and #246 MiniWebApp layout.
Goal
Set $_SERVER['DOCUMENT_ROOT'] to the absolute docroot directory passed to phpc serve / bin/serve.php (trailing slash optional, match Zend convention).
Scope
Acceptance criteria
./phpc serve 127.0.0.1:8080 examples/001-SimpleWeb
php -r '/* via PHPT or fixture */' # asserts DOCUMENT_ROOT ends with 001-SimpleWeb
phpc lint scripts using $_SERVER['DOCUMENT_ROOT'] do not fail on undefined index (#273).
Verification (local / Docker only)
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
./script/ci-local.sh --filter web_document_root
No GitHub Actions required.
Dependencies
Related
Files
lib/Web/Superglobals.php, bin/serve.php
lib/AOT/runtime/superglobals_refresh.c
Problem
PHP apps and frameworks use
$_SERVER['DOCUMENT_ROOT']to resolve includes, templates, and static asset paths. The compiler dev server serves static files from a docroot (#150 closed) but does not exposeDOCUMENT_ROOTin$_SERVER, so scripts cannot build paths like:This blocks #54 include paths, #194
fopentemplates, and #246 MiniWebApp layout.Goal
Set
$_SERVER['DOCUMENT_ROOT']to the absolute docroot directory passed tophpc serve/bin/serve.php(trailing slash optional, match Zend convention).Scope
Superglobals::populateServer()— readDOCUMENT_ROOTfrom env or accept explicit parameter from serve driverputenv('DOCUMENT_ROOT=' . realpath($docroot))before each requestsuperglobals_refresh.ccopiesDOCUMENT_ROOTwhen present in envDOCUMENT_ROOTmatches expected pathAcceptance criteria
phpc lintscripts using$_SERVER['DOCUMENT_ROOT']do not fail on undefined index (#273).Verification (local / Docker only)
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \ ./script/ci-local.sh --filter web_document_rootNo GitHub Actions required.
Dependencies
DOCUMENT_ROOTper CGI/1.1 specRelated
Files
lib/Web/Superglobals.php,bin/serve.phplib/AOT/runtime/superglobals_refresh.c