diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
index 01a1e4da7f..919713cd05 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
@@ -44,7 +44,8 @@ class ServerRunCommand extends ContainerAwareCommand
{
$this
->setDefinition(array(
- new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
+ new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1'),
+ new InputOption('port', 'p', InputOption::VALUE_REQUIRED, 'Address port number', '8000'),
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
))
@@ -101,10 +102,15 @@ EOF
$output->writeln('Running PHP built-in server in production environment is NOT recommended!');
}
- $output->writeln(sprintf("Server running on http://%s\n", $input->getArgument('address')));
+ $address = $input->getArgument('address');
+ if (false === strpos($address, ':')) {
+ $address = $address.':'.$input->getOption('port');
+ }
+
+ $output->writeln(sprintf("Server running on http://%s\n", $address));
$output->writeln('Quit the server with CONTROL-C.');
- if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
+ if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env, $address)) {
return 1;
}
@@ -131,7 +137,7 @@ EOF
return $process->getExitCode();
}
- private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env)
+ private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env, $address)
{
$router = $input->getOption('router') ?: $this
->getContainer()
@@ -154,6 +160,6 @@ EOF
return;
}
- return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
+ return new ProcessBuilder(array($binary, '-S', $address, $router));
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php
index 9110bb1b43..c919dfa00c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php
@@ -33,7 +33,8 @@ class ServerStartCommand extends ServerCommand
{
$this
->setDefinition(array(
- new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
+ new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1'),
+ new InputOption('port', 'p', InputOption::VALUE_REQUIRED, 'Address port number', '8000'),
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
))
@@ -101,9 +102,7 @@ EOF
$address = $input->getArgument('address');
if (false === strpos($address, ':')) {
- $output->writeln('The address has to be of the form bind-address:port.');
-
- return 1;
+ $address = $address.':'.$input->getOption('port');
}
if ($this->isOtherServerProcessRunning($address)) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStopCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStopCommand.php
index 9b0656c220..c40952059a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStopCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStopCommand.php
@@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Input\InputOption;
/**
* Stops a background process running PHP's built-in web server.
@@ -29,7 +30,8 @@ class ServerStopCommand extends ServerCommand
{
$this
->setDefinition(array(
- new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
+ new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1'),
+ new InputOption('port', 'p', InputOption::VALUE_REQUIRED, 'Address port number', '8000'),
))
->setName('server:stop')
->setDescription('Stops PHP\'s built-in web server that was started with the server:start command')
@@ -53,6 +55,10 @@ EOF
protected function execute(InputInterface $input, OutputInterface $output)
{
$address = $input->getArgument('address');
+ if (false === strpos($address, ':')) {
+ $address = $address.':'.$input->getOption('port');
+ }
+
$lockFile = $this->getLockFile($address);
if (!file_exists($lockFile)) {