8000 Improved exception message · symfony/symfony@df46188 · GitHub
[go: up one dir, main page]

Skip to content

Commit df46188

Browse files
committed
Improved exception message
1 parent b9b6ebd commit df46188

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/Symfony/Bundle/WebServerBundle/WebServerConfig.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function __construct($documentRoot, $env, $address = null, $router = null
2828
throw new \InvalidArgumentException(sprintf('The document root directory "%s" does not exist.', $documentRoot));
2929
}
3030

31-
if (null === $file = $this->guessFrontController($documentRoot, $env)) {
32-
throw new \InvalidArgumentException(sprintf('Unable to guess the front controller under "%s".', $documentRoot));
31+
if (null === $file = $this->findFrontController($documentRoot, $env)) {
32+
throw new \InvalidArgumentException(sprintf('Unable to find the front controller under "%s" (none of these files exist: %s).', $documentRoot, implode(', ', $this->getFrontControllerFileNames($env))));
3333
}
3434

3535
putenv('APP_FRONT_CONTROLLER='.$file);
@@ -87,21 +87,22 @@ public function getAddress()
8787
return $this->hostname.':'.$this->port;
8888
}
8989

90-
private function guessFrontController($documentRoot, $env)
90+
private function findFrontController($documentRoot, $env)
9191
{
92-
foreach (array('app', 'index') as $prefix) {
93-
$file = sprintf('%s_%s.php', $prefix, $env);
94-
if (file_exists($documentRoot.'/'.$file)) {
95-
return $file;
96-
}
92+
$fileNames = $this->getFrontControllerFileNames($env);
9793

98-
$file = sprintf('%s.php', $prefix);
99-
if (file_exists($documentRoot.'/'.$file)) {
100-
return $file;
94+
foreach ($fileNames as $fileName) {
95+
if (file_exists($documentRoot.'/'.$fileName)) {
96+
return $fileName;
10197
}
10298
}
10399
}
104100

101+
private function getFrontControllerFileNames($env)
102+
{
103+
return array('app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php');
104+
}
105+
105106
private function findBestPort()
106107
{
107108
$port = 8000;

0 commit comments

Comments
 (0)
0