| Total Complexity | 9 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | class ServeCommand extends Command |
||
| 19 | { |
||
| 20 | /** @var string */ |
||
| 21 | protected $signature = 'serve {--host= : <comment>[default: "localhost"]</comment>}} {--port= : <comment>[default: 8080]</comment>}'; |
||
| 22 | |||
| 23 | /** @var string */ |
||
| 24 | protected $description = 'Start the realtime compiler server.'; |
||
| 25 | |||
| 26 | public function handle(): int |
||
| 27 | { |
||
| 28 | $this->line('<info>Starting the HydeRC server...</info> Press Ctrl+C to stop'); |
||
| 29 | |||
| 30 | $this->runServerProcess(sprintf('php -S %s:%d %s', |
||
| 31 | $this->getHostSelection() ?: 'localhost', |
||
| 32 | $this->getPortSelection() ?: 8080, |
||
| 33 | $this->getExecutablePath() |
||
| 34 | )); |
||
| 35 | |||
| 36 | return Command::SUCCESS; |
||
| 37 | } |
||
| 38 | |||
| 39 | protected function getPortSelection(): int |
||
| 42 | } |
||
| 43 | |||
| 44 | protected function getHostSelection(): string |
||
| 45 | { |
||
| 46 | return $this->option('host') ?: config('hyde.server.host', 'localhost'); |
||
| 47 | } |
||
| 48 | |||
| 49 | protected function getExecutablePath(): string |
||
| 52 | } |
||
| 53 | |||
| 54 | protected function runServerProcess(string $command): void |
||
| 58 | }); |
||
| 59 | } |
||
| 61 |