Skip to content

Stdlib: get_include_path() / set_include_path() / restore_include_path() — include path stack (bootstrap) #3223

Description

@PurHur

Category

stdlib | bootstrap

Problem

Zend maintains an include_path stack used by include/require and stream_resolve_include_path(). This compiler resolves literal includes via #475 / deploy root, but does not implement the standard functions to read or mutate include_path — breaking Composer-style bootstraps and php.ini parity probes.

Verified 2026-06-05: function_exists('get_include_path') → false on bin/vm.php; stream_resolve_include_path() also missing (#6051).

php-src reference

Repro (failure today)

<?php
foreach (['get_include_path', 'set_include_path', 'restore_include_path'] as $fn) {
    echo $fn, '=', function_exists($fn) ? 'yes' : 'no', "\n";
}
$dir = sys_get_temp_dir() . '/phpc_inc_' . getmypid();
mkdir($dir);
file_put_contents($dir . '/only_here.php', '<?php return "found";');
$old = set_include_path($dir . PATH_SEPARATOR . get_include_path());
$r = include 'only_here.php';
restore_include_path();
@unlink($dir . '/only_here.php');
@rmdir($dir);
echo "include=", var_export($r, true), "\n";
docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro_include_path.php
php bin/vm.php repro_include_path.php
'
Step Zend PHP 8.x bin/vm.php (today)
get_include_path exists yes no ❌
set_include_path + include 'only_here.php' include='found' fatal/undefined ❌
restore_include_path pops stack previous path restored n/a

Scope (PHP-in-PHP)

Layer Path
VM state lib/VM/Context.php or Runtime — PATH_SEPARATOR-split stack, default .
Builtins ext/standard/get_include_path.php, set_include_path.php, restore_include_path.php
Include resolver lib/VM.php / lib/Compiler.php TYPE_INCLUDE — search stack after deploy root
Register ext/standard/Module.php
Follow-up #6051 stream_resolve_include_path() shares same stack
Tests test/compliance/cases/stdlib/include_path_stack.phpt
Bootstrap re-run php script/bootstrap-inventory.php --check after wiring

Forbidden: internal_* shims — wire real include resolution.

Done when

  • Repro table: all three functions registered; include='found' on VM
  • set_include_path() returns previous path string; nested calls stack correctly
  • restore_include_path() pops one level; empty stack restores ini/default .
  • PHPT documents interaction with PHPC_DEPLOY_ROOT / AOT: PHPC_DEPLOY_ROOT for runtime template includes in deployed binaries #585
  • ./script/ci-fast.sh --filter include_path green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter include_path'

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MOST IMPORTANTThis are the most important targetsarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions