Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitabb8d2b

Browse files
committed
feature#22316 [WebServerBundle] added a way to dump current status host/port/address when getting the status (fabpot)
This PR was merged into the 3.3-dev branch.Discussion----------[WebServerBundle] added a way to dump current status host/port/address when getting the status| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/aNow that the web server can run on an automatically chosen port, it's more complex to integrate it into tests (I want to run some functional tests locally).The `server:status` command gives this information, but not in a machine-readable way.I propose to add a `--filter` flag to fix that:`./bin/console server:status --filter=address`Commits-------b417b62 [WebServerBundle] added a way to dump current status host/port/address when getting the status
2 parents3458edf +b417b62 commitabb8d2b

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

‎src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected function configure()
3535
->setName('server:status')
3636
->setDefinition(array(
3737
newInputOption('pidfile',null, InputOption::VALUE_REQUIRED,'PID file'),
38+
newInputOption('filter',null, InputOption::VALUE_REQUIRED,'The value to display (one of port, host, or address)'),
3839
))
3940
->setDescription('Outputs the status of the local web server for the given address')
4041
;
@@ -47,10 +48,29 @@ protected function execute(InputInterface $input, OutputInterface $output)
4748
{
4849
$io =newSymfonyStyle($input,$outputinstanceof ConsoleOutputInterface ?$output->getErrorOutput() :$output);
4950
$server =newWebServer();
50-
if ($server->isRunning($input->getOption('pidfile'))) {
51-
$io->success(sprintf('Web server still listening on http://%s',$server->getAddress($input->getOption('pidfile'))));
51+
if ($filter =$input->getOption('filter')) {
52+
if ($server->isRunning($input->getOption('pidfile'))) {
53+
list($host,$port) =explode(':',$address =$server->getAddress($input->getOption('pidfile')));
54+
if ('address' ===$filter) {
55+
$output->write($address);
56+
}elseif ('host' ===$filter) {
57+
$output->write($host);
58+
}elseif ('port' ===$filter) {
59+
$output->write($port);
60+
}else {
61+
thrownew \InvalidArgumentException(sprintf('"%s" is not a valid filter.',$filter));
62+
}
63+
}else {
64+
return1;
65+
}
5266
}else {
53-
$io->warning('No web server is listening.');
67+
if ($server->isRunning($input->getOption('pidfile'))) {
68+
$io->success(sprintf('Web server still listening on http://%s',$server->getAddress($input->getOption('pidfile'))));
69+
}else {
70+
$io->warning('No web server is listening.');
71+
72+
return1;
73+
}
5474
}
5575
}
5676
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp