Skip to content

Commit

Permalink
Merge pull request #7 from AhrimFakhriy/master
Browse files Browse the repository at this point in the history
Add support for options such as host and port to serve.
  • Loading branch information
bangnokia authored Feb 19, 2021
2 parents cc2cee1 + 66ced12 commit e92e5e5
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

class ServeCommand extends Command
{
protected $signature = 'serve';
protected $signature = 'serve
{--host= : The host address to serve the application on}
{--port= : The port to serve the application on}
{--tries= : The max number of ports to attempt to serve from}
{--no-reload : Do not reload the development server on .env file changes}';

protected $description = 'Serve the application on the PHP development server';

Expand All @@ -18,7 +22,7 @@ public function handle()
$artisanPath = base_path('artisan');

$processes = [
$httpProcess = new Process([$phpBinaryPath, $artisanPath, 'serve:http']),
$httpProcess = new Process([$phpBinaryPath, $artisanPath, 'serve:http', ...$this->serveOptions()]),
$socketProcess = new Process([$phpBinaryPath, $artisanPath, 'serve:websockets']),
];

Expand Down Expand Up @@ -46,4 +50,19 @@ public function handle()
sleep(1);
}
}
}

public function serveOptions()
{
return collect($this->options())
->filter(function($option) {
return $option;

})->map(function($value, $key) {
if(is_bool($value))
return "--{$key}";

return "--{$key}={$value}";

})->values();
}
}

0 comments on commit e92e5e5

Please sign in to comment.