Skip to content

Commit 07f3550

Browse files
committed
fix(envlite): resolve router paths via DOCUMENT_ROOT
The router previously used dirname(__DIR__, 2) . '/src' to locate both the static-file root and the front controller. That resolves relative to the router file's own checkout, so invoking envlite from a different worktree loaded the wrong wp-config.php and triggered a canonical-URL 301 to that wp-config's WP_HOME port. Use $_SERVER['DOCUMENT_ROOT'] instead — populated by php -S from its -t flag, which envlite_run_dev_server already points at the target repo's src/.
1 parent 28c6332 commit 07f3550

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tools/local-env/router.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
return true;
99
}
1010

11-
$file = dirname(__DIR__, 2) . '/src' . $path;
11+
// DOCUMENT_ROOT is the absolute resolution of php -S's -t flag. Using it
12+
// instead of a path computed from __DIR__ lets the router live outside the
13+
// target repo (e.g. envlite invoked from a different checkout).
14+
$docroot = $_SERVER['DOCUMENT_ROOT'];
15+
$file = $docroot . $path;
1216

1317
if ($path !== '/' && file_exists($file)) {
1418
if (!is_dir($file)) {
@@ -22,4 +26,4 @@
2226
}
2327
}
2428

25-
require dirname(__DIR__, 2) . '/src/index.php';
29+
require $docroot . '/index.php';

0 commit comments

Comments
 (0)