Skip to content

Commit cc0e492

Browse files
committed
Smarter frontControllerDirectory method
The previous method simply returned `web` if there was a file named `craft` in the $sitePath (which means we’re running Craft 3). The problem is that many sites, especially upgraded ones, will be serving out of `public`. This is also in line with the default Forge/ServerPilot default dirs. So we test to see if either `/web` or `/public` exist, and return them if so. Otherwise default to the current method. Signed-off-by: Andrew Welch <[email protected]>
1 parent e5f9914 commit cc0e492

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cli/drivers/CraftValetDriver.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public function serves($sitePath, $siteName, $uri)
2323
*/
2424
public function frontControllerDirectory($sitePath)
2525
{
26+
$dirs = ['web', 'public'];
27+
28+
foreach ($dirs as $dir) {
29+
if (is_dir($sitePath.'/'.$dir)) {
30+
return $dir;
31+
}
32+
}
33+
// Give up, and just return the default
2634
return is_file($sitePath.'/craft') ? 'web' : 'public';
2735
}
2836

0 commit comments

Comments
 (0)