Skip to content

Commit bf463da

Browse files
authored
Merge pull request #97 from fschwaiger/feature/basic-valet-driver-docroot
Set DOCUMENT_ROOT correctly when serving index.php files.
2 parents 15b2ecb + d9adae9 commit bf463da

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cli/drivers/BasicValetDriver.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,22 @@ public function frontControllerPath($sitePath, $siteName, $uri)
5454
if ($this->isActualFile($candidate)) {
5555
$_SERVER['SCRIPT_FILENAME'] = $candidate;
5656
$_SERVER['SCRIPT_NAME'] = str_replace($sitePath, '', $candidate);
57+
$_SERVER['DOCUMENT_ROOT'] = $sitePath;
5758
return $candidate;
5859
}
5960
}
6061

61-
$fixedCandidates = [
62-
$this->asRootPhpIndexFile($sitePath),
63-
$this->asPublicPhpIndexFile($sitePath),
64-
$this->asPublicHtmlIndexFile($sitePath),
62+
$fixedCandidatesAndDocroots = [
63+
$this->asRootPhpIndexFile($sitePath) => $sitePath,
64+
$this->asPublicPhpIndexFile($sitePath) => $sitePath . '/public',
65+
$this->asPublicHtmlIndexFile($sitePath) => $sitePath . '/public',
6566
];
6667

67-
foreach ($fixedCandidates as $candidate) {
68+
foreach ($fixedCandidatesAndDocroots as $candidate => $docroot) {
6869
if ($this->isActualFile($candidate)) {
6970
$_SERVER['SCRIPT_FILENAME'] = $candidate;
7071
$_SERVER['SCRIPT_NAME'] = '/index.php';
72+
$_SERVER['DOCUMENT_ROOT'] = $docroot;
7173
return $candidate;
7274
}
7375
}

0 commit comments

Comments
 (0)