-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli
39 lines (32 loc) · 958 Bytes
/
cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env php
<?php
use Phalcon\Cli\Dispatcher;
use Phalcon\Cli\Router;
use Phalcon\Config;
use PhalconExt\Cli\Console;
use PhalconExt\Example\MainTask;
use PhalconExt\Example\OtherTask;
// Di instance can be same as for web app!
$di = require __DIR__ . '/bootstrap.php';
// But here we use cli router, dispatcher and writer!
$di->setShared('dispatcher', Dispatcher::class);
$di->setShared('router', Router::class);
$di->get('config')->merge(new Config([
// You might want to have console config in some file
'console' => [
'tasks' => [
// Name => FQCN
'main' => MainTask::class,
'other' => OtherTask::class,
],
],
]));
$cli = new Console($di, 'ExampleApp', '0.0.1');
try {
$cli->handle($_SERVER['argv']);
} catch (\Throwable $e) {
$di->get('interactor')->eol()
->errorBold($e->getMessage(), true)
->comment($e->getTraceAsString(), true);
exit(255);
}