10000 minor #11844 [FrameworkBundle] improve handling router script paths (… · symfony/symfony@91fb103 · GitHub
[go: up one dir, main page]

Skip to content

Commit 91fb103

committed
minor #11844 [FrameworkBundle] improve handling router script paths (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle] improve handling router script paths | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | The `server:run` command switches the working directory before starting the built-in web server. Therefore, the path to a custom router script had to be specified based on the document root path and not based on the user's working directory. Another option is to update the documentation (as started in symfony/symfony-docs#4194). Though I think the current behaviour is a bug. The intended behaviour can be derived from the command's help message: > ``` If you have custom docroot directory layout, you can specify your own router script using --router option: > ./app/console server:run --router=app/config/router.php ``` As you can see, the path is specified based on the current working directory. Commits ------- 0a16cf2 improve handling router script paths
2 parents f4c9c97 + 0a16cf2 commit 91fb103

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
101101
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
102102
;
103103

104+
if (!file_exists($router)) {
105+
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));
106+
107+
return 1;
108+
}
109+
110+
$router = realpath($router);
111+
104112
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
105113

106114
$builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));

0 commit comments

Comments
 (0)
0