[WebServerBundle] Fix router script path and check existence

This commit is contained in:
Gábor Egyed 2017-06-14 13:38:13 +02:00
parent 1a3d42fc56
commit aeab2fe1f7

View File

@ -36,7 +36,18 @@ class WebServerConfig
$this->documentRoot = $documentRoot;
$this->env = $env;
$this->router = $router ?: __DIR__.'/Resources/router.php';
if (null !== $router) {
$absoluteRouterPath = realpath($router);
if (false === $absoluteRouterPath) {
throw new \InvalidArgumentException(sprintf('Router script "%s" does not exist.', $router));
}
$this->router = $absoluteRouterPath;
} else {
$this->router = __DIR__.'/Resources/router.php';
}
if (null === $address) {
$this->hostname = '127.0.0.1';