Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
HydeServeCommand
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 handle
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Hyde\Framework\Commands;
4
5use Hyde\Framework\Hyde;
6use LaravelZero\Framework\Commands\Command;
7
8/**
9 * Start the realtime compiler server.
10 */
11class HydeServeCommand extends Command
12{
13    /**
14     * The signature of the command.
15     *
16     * @var string
17     */
18    protected $signature = 'serve {--port=8080} {--host=localhost}';
19
20    /**
21     * The description of the command.
22     *
23     * @var string
24     */
25    protected $description = 'Start the experimental realtime compiler.';
26
27    /**
28     * Execute the console command.
29     *
30     * @return int
31     */
32    public function handle(): int
33    {
34        $this->line('<info>Starting the server...</info> Press Ctrl+C to stop');
35
36        $this->warn('Running experimental HydeRC 2.0. Please report any issues on GitHub.');
37
38        $port = $this->option('port');
39        $host = $this->option('host');
40        $command = "php -S $host:$port ".Hyde::path('vendor/hyde/realtime-compiler/bin/server.php');
41        if (app()->environment('testing')) {
42            $command = 'echo '.$command;
43        }
44        passthru($command);
45
46        return 0;
47    }
48}