Skip to content

Commit d997021

Browse files
authored
Merge pull request #1072 from jakubtobiasz/fix-for-symfony5-and-up
Set the $_SERVER['SCRIPT_FILENAME'] to the front controller path
2 parents f1c1400 + dbf8f0b commit d997021

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

cli/drivers/SymfonyValetDriver.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,17 @@ public function isStaticFile($sitePath, $siteName, $uri)
4747
*/
4848
public function frontControllerPath($sitePath, $siteName, $uri)
4949
{
50-
if (file_exists($frontControllerPath = $sitePath.'/web/app_dev.php')) {
51-
return $frontControllerPath;
52-
} elseif (file_exists($frontControllerPath = $sitePath.'/web/app.php')) {
53-
return $frontControllerPath;
54-
} elseif (file_exists($frontControllerPath = $sitePath.'/public/index.php')) {
55-
return $frontControllerPath;
50+
$frontControllerPath = null;
51+
52+
if (file_exists($path = $sitePath.'/web/app_dev.php')) {
53+
$frontControllerPath = $path;
54+
} elseif (file_exists($path = $sitePath.'/web/app.php')) {
55+
$frontControllerPath = $path;
56+
} elseif (file_exists($path = $sitePath.'/public/index.php')) {
57+
$frontControllerPath = $path;
5658
}
59+
60+
$_SERVER['SCRIPT_FILENAME'] = $frontControllerPath;
61+
return $frontControllerPath;
5762
}
5863
}

server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ function show_valet_404()
2121
* Show directory listing or 404 if directory doesn't exist.
2222
*/
2323
function show_directory_listing($valetSitePath, $uri)
24-
{
24+
{
2525
$is_root = ($uri == '/');
2626
$directory = ($is_root) ? $valetSitePath : $valetSitePath.$uri;
2727

28-
if (!file_exists($directory)) {
29-
show_valet_404();
28+
if (!file_exists($directory)) {
29+
show_valet_404();
3030
}
3131

3232
// Sort directories at the top

0 commit comments

Comments
 (0)