Problem
Multi-file web apps resolve templates with __DIR__ includes (#85) and need path builtins for guards:
$tpl = __DIR__ . '/../templates/home.php';
if (is_file($tpl)) { include $tpl; }
examples/003-MiniWebApp uses __DIR__ only today; dirname / realpath are still missing from ext/standard/Module.php for portable config loading.
Goal
dirname, basename, and realpath with PHP semantics on VM; JIT string paths where arguments are compile-time literals; AOT via libc realpath(3) FFI or VM fallback.
Implementation hints
| Builtin |
VM |
JIT |
Registration |
dirname |
Pure string (PHP rules for / and .) |
Literal fold when arg is const string |
ext/standard/dirname.php |
basename |
Same |
Literal fold |
ext/standard/basename.php |
realpath |
realpath() native or FFI |
Call libc when path is literal |
ext/standard/realpath.php |
| Step |
Files |
| 1 |
Add PHP implementations under ext/standard/ |
| 2 |
Register in ext/standard/Module.php |
| 3 |
JIT handlers in lib/JIT/Builtin/ (or VM-only first) |
| 4 |
test/compliance/cases/stdlib_dirname.phpt, stdlib_realpath_missing.phpt |
| 5 |
script/capability-matrix.php rows |
Interaction with web stack
Acceptance criteria
./script/ci-fast.sh --filter 'dirname|realpath'
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
php bin/vm.php -r 'echo dirname("/var/www/public/index.php");'
# /var/www/public
PHPT: realpath returns false on missing path (PHP semantics).
Verification
Local/Docker only — not GitHub Actions.
Dependencies
Related
Problem
Multi-file web apps resolve templates with
__DIR__includes (#85) and need path builtins for guards:examples/003-MiniWebAppuses__DIR__only today;dirname/realpathare still missing fromext/standard/Module.phpfor portable config loading.Goal
dirname,basename, andrealpathwith PHP semantics on VM; JIT string paths where arguments are compile-time literals; AOT via libcrealpath(3)FFI or VM fallback.Implementation hints
dirname/and.)ext/standard/dirname.phpbasenameext/standard/basename.phprealpathrealpath()native or FFIext/standard/realpath.phpext/standard/ext/standard/Module.phplib/JIT/Builtin/(or VM-only first)test/compliance/cases/stdlib_dirname.phpt,stdlib_realpath_missing.phptscript/capability-matrix.phprowsInteraction with web stack
realpathbeforeincludefor securityrealpathredundant for templates; still needed for upload dirsfile_get_contentson resolved pathsAcceptance criteria
PHPT:
realpathreturnsfalseon missing path (PHP semantics).Verification
Local/Docker only — not GitHub Actions.
Dependencies
__DIR__/__FILE__Related
examples/003-MiniWebApp/templates/