forked from SachaMorard/phalcon-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.example.php
More file actions
31 lines (26 loc) · 893 Bytes
/
console.example.php
File metadata and controls
31 lines (26 loc) · 893 Bytes
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
#!/usr/bin/env php
<?php
use Phalcon\Script;
use Phalcon\Script\Color;
use Phalcon\Commands\CommandsListener;
use Phalcon\Exception as PhalconException;
use Phalcon\Events\Manager as EventsManager;
try {
// Bellow, include your bootstrap, for example:
require __DIR__ . '/app/bootstrap_cli.php';
$eventsManager = new EventsManager();
$eventsManager->attach('command', new CommandsListener());
$script = new Script($eventsManager);
$script->loadUserScripts();
$commandsToEnable = $di->get('config')->commandsToEnable;
foreach ($commandsToEnable as $command) {
$script->attach(new $command($script, $eventsManager));
}
$script->run();
} catch (PhalconException $e) {
fwrite(STDERR, Color::error($e->getMessage()) . PHP_EOL);
exit(1);
} catch (Exception $e) {
fwrite(STDERR, 'ERROR: ' . $e->getMessage() . PHP_EOL);
exit(1);
}