ServeCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 52
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 0 14 1
A getOptions() 0 8 1
1
<?php
2
3
namespace App\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputOption;
7
use Symfony\Component\Process\ProcessUtils;
8
9
class ServeCommand extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'serve';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Serve the application on the PHP development server';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @throws \Exception
29
     *
30
     * @return void
31
     */
32
    public function fire()
33
    {
34
        chdir($this->laravel->publicPath());
35
36
        $host = $this->input->getOption('host');
37
38
        $port = $this->input->getOption('port');
39
40
        $base = ProcessUtils::escapeArgument($this->laravel->basePath());
41
42
        $this->info("Laravel development server started on http://{$host}:{$port}/");
43
44
        passthru("php -S {$host}:{$port} {$base}/server.php & node ../nodejs/socket {$host}");
45
    }
46
47
    /**
48
     * Get the console command options.
49
     *
50
     * @return array
51
     */
52
    protected function getOptions()
53
    {
54
        return [
55
            ['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', '127.0.0.1'],
56
57
            ['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000],
58
        ];
59
    }
60
}
61