1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the O2System PHP Framework package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @author Steeve Andrian Salim |
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
13
|
|
|
|
14
|
|
|
namespace O2System\Reactor\Cli\Commanders; |
15
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
17
|
|
|
|
18
|
|
|
use O2System\Kernel\Cli\Commander; |
19
|
|
|
use O2System\Kernel\Cli\Writers\Format; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class Make |
23
|
|
|
* |
24
|
|
|
* @package O2System\Reactor\Cli\Commanders |
25
|
|
|
*/ |
26
|
|
|
class Serve extends Commander |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Make::$commandVersion |
30
|
|
|
* |
31
|
|
|
* Command version. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $commandVersion = '1.0.0'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Make::$commandDescription |
39
|
|
|
* |
40
|
|
|
* Command description. |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $commandDescription = 'CLI_SERVE_DESC'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Make::$commandOptions |
48
|
|
|
* |
49
|
|
|
* Command options. |
50
|
|
|
* |
51
|
|
|
* @var array |
52
|
|
|
*/ |
53
|
|
|
protected $commandOptions = [ |
54
|
|
|
'host' => [ |
55
|
|
|
'description' => 'CLI_SERVE_HOST_HELP', |
56
|
|
|
'required' => false, |
57
|
|
|
], |
58
|
|
|
'port' => [ |
59
|
|
|
'description' => 'CLI_SERVE_PORT_HELP', |
60
|
|
|
'required' => false, |
61
|
|
|
], |
62
|
|
|
]; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Serve::$host |
66
|
|
|
* |
67
|
|
|
* Serve host. |
68
|
|
|
* |
69
|
|
|
* @var string |
70
|
|
|
*/ |
71
|
|
|
protected $optionHost; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Serve::$port |
75
|
|
|
* |
76
|
|
|
* Serve port. |
77
|
|
|
* |
78
|
|
|
* @var int |
79
|
|
|
*/ |
80
|
|
|
protected $optionPort; |
81
|
|
|
|
82
|
|
|
public function optionHost($host) |
83
|
|
|
{ |
84
|
|
|
$this->optionHost = $host; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function optionPort($port) |
88
|
|
|
{ |
89
|
|
|
$this->optionPort = $port; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function execute() |
93
|
|
|
{ |
94
|
|
|
$options = input()->get(); |
95
|
|
|
|
96
|
|
|
if (empty($options)) { |
97
|
|
|
$_GET[ 'host' ] = 'localhost'; |
98
|
|
|
$_GET[ 'port' ] = 8000; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
parent::execute(); |
102
|
|
|
|
103
|
|
|
output()->write( |
|
|
|
|
104
|
|
|
(new Format()) |
105
|
|
|
->setContextualClass(Format::SUCCESS) |
106
|
|
|
->setString(language()->getLine('CLI_SERVE_STARTED', [$this->optionHost, $this->optionPort])) |
107
|
|
|
->setNewLinesAfter(1) |
108
|
|
|
); |
109
|
|
|
|
110
|
|
|
$_SERVER[ 'DOCUMENT_ROOT' ] = PATH_PUBLIC; |
111
|
|
|
|
112
|
|
|
output()->write( |
113
|
|
|
(new Format()) |
114
|
|
|
->setContextualClass(Format::INFO) |
115
|
|
|
->setString(language()->getLine('CLI_SERVE_DOC_ROOT', [$_SERVER[ 'DOCUMENT_ROOT' ]])) |
116
|
|
|
->setNewLinesAfter(1) |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
output()->write( |
120
|
|
|
(new Format()) |
121
|
|
|
->setContextualClass(Format::WARNING) |
122
|
|
|
->setString(language()->getLine('CLI_SERVE_STOP')) |
123
|
|
|
->setNewLinesAfter(1) |
124
|
|
|
); |
125
|
|
|
|
126
|
|
|
/* |
127
|
|
|
* Call PHP's built-in webserver, making sure to set our |
128
|
|
|
* base path to the public folder, and to use the rewrite file |
129
|
|
|
* to ensure our environment is set and it simulates basic mod_rewrite. |
130
|
|
|
*/ |
131
|
|
|
passthru('php -S ' . |
132
|
|
|
$this->optionHost . |
133
|
|
|
':' . |
134
|
|
|
$this->optionPort . |
135
|
|
|
' -t ' . |
136
|
|
|
str_replace('\\', DIRECTORY_SEPARATOR, DIR_PUBLIC) . ' ' . PATH_ROOT . 'server.php' |
|
|
|
|
137
|
|
|
); |
138
|
|
|
} |
139
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.