Skip to content

Commit 6a18e73

Browse files
committed
tweaks to server command. respect explicit port.
1 parent a1c039c commit 6a18e73

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Illuminate/Foundation/Console/ServeCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ protected function host()
8686
*/
8787
protected function port()
8888
{
89-
return $this->input->getOption('port') + $this->portOffset;
89+
$port = $this->input->getOption('port') ?: 8000;
90+
91+
return $port + $this->portOffset;
9092
}
9193

9294
/**
@@ -96,7 +98,8 @@ protected function port()
9698
*/
9799
protected function canTryAnotherPort()
98100
{
99-
return $this->input->getOption('tries') > $this->portOffset;
101+
return is_null($this->input->getOption('port')) &&
102+
($this->input->getOption('tries') > $this->portOffset);
100103
}
101104

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

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

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

0 commit comments

Comments
 (0)