Skip to content

Commit

Permalink
tweaks to server command. respect explicit port.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 15, 2019
1 parent a1c039c commit 6a18e73
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Illuminate/Foundation/Console/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ protected function host()
*/
protected function port()
{
return $this->input->getOption('port') + $this->portOffset;
$port = $this->input->getOption('port') ?: 8000;

return $port + $this->portOffset;
}

/**
Expand All @@ -96,7 +98,8 @@ protected function port()
*/
protected function canTryAnotherPort()
{
return $this->input->getOption('tries') > $this->portOffset;
return is_null($this->input->getOption('port')) &&
($this->input->getOption('tries') > $this->portOffset);
}

/**
Expand All @@ -109,7 +112,7 @@ protected function getOptions()
return [
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on', '127.0.0.1'],

['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on', env('SERVER_PORT', 8000)],
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on', $_ENV['SERVER_PORT'] ?? null],

['tries', null, InputOption::VALUE_OPTIONAL, 'The max number of ports to attempt to serve from', 10],
];
Expand Down

0 comments on commit 6a18e73

Please sign in to comment.