8000 minor #21407 [WebServerBundle] Improved exception message (wouterj) · symfony/symfony@87273d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 87273d9

Browse files
committed
minor #21407 [WebServerBundle] Improved exception message (wouterj)
This PR was merged into the 3.3-dev branch. Discussion ---------- [WebServerBundle] Improved exception message | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This is a quite minor one, but imo "guessing" is something that's optional. If I don't pass value X, a script will guess value X. However, in this case, the front controller file cannot be specified. It has to be one of the "guessed" file names. That's why I renamed "guessing" to "finding". While doing this, I also added the possible file names in the exception message to ease fixing problems. Commits ------- df46188 Improved exception message
2 parents caba97a + df46188 commit 87273d9

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< 8000 span class="x">->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