1 | <?php |
||
12 | class Command |
||
13 | { |
||
14 | protected $pidFile; |
||
15 | |||
16 | protected $options = []; |
||
17 | |||
18 | protected $host = 'localhost'; |
||
19 | |||
20 | protected $port = 8083; |
||
21 | |||
22 | protected $bootstrap = 'bootstrap/app.php'; |
||
23 | |||
24 | protected $serverOptions = []; |
||
25 | |||
26 | public function __construct() |
||
30 | |||
31 | public static function main($argv) |
||
37 | |||
38 | public function run($argv) |
||
49 | |||
50 | /** |
||
51 | * @param array $argv |
||
52 | * |
||
53 | * @return void |
||
54 | */ |
||
55 | public function handleAction($argv) |
||
67 | |||
68 | public function handleArguments() |
||
120 | |||
121 | /** |
||
122 | * Show usage. |
||
123 | */ |
||
124 | public function usage() |
||
128 | |||
129 | /** |
||
130 | * Stop the server. |
||
131 | * |
||
132 | * @throws \Exception |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | public function stop() |
||
150 | |||
151 | /** |
||
152 | * Reload the server. |
||
153 | * |
||
154 | * @throws \Exception |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | public function reload() |
||
162 | |||
163 | /** |
||
164 | * Restart the server. |
||
165 | * |
||
166 | * @return void |
||
167 | */ |
||
168 | public function restart() |
||
180 | |||
181 | /** |
||
182 | * Get process identifier of this server. |
||
183 | * |
||
184 | * @throws \Exception |
||
185 | * |
||
186 | * @return bool|string |
||
187 | */ |
||
188 | protected function getPid() |
||
206 | |||
207 | /** |
||
208 | * Set the error handling for the application. |
||
209 | * |
||
210 | * @return void |
||
211 | */ |
||
212 | protected function registerErrorHandling() |
||
230 | |||
231 | /** |
||
232 | * Handle an uncaught exception instance. |
||
233 | * |
||
234 | * @param \Throwable $e |
||
235 | * @return void |
||
236 | */ |
||
237 | protected function handleUncaughtException($e) |
||
245 | |||
246 | /** |
||
247 | * Handle the application shutdown routine. |
||
248 | * |
||
249 | * @return void |
||
250 | */ |
||
251 | protected function handleShutdown() |
||
263 | |||
264 | /** |
||
265 | * Determine if the error type is fatal. |
||
266 | * |
||
267 | * @param int $type |
||
268 | * @return bool |
||
269 | */ |
||
270 | protected function isFatalError($type) |
||
280 | } |
||
281 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.