forked from opncell/opncell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phalcon
executable file
·84 lines (75 loc) · 2.6 KB
/
phalcon
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env php
<?php
/**
* This file is part of the Phalcon Developer Tools.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
use Phalcon\DevTools\Commands\Builtin\AllModels;
use Phalcon\DevTools\Commands\Builtin\Console;
use Phalcon\DevTools\Commands\Builtin\Controller;
use Phalcon\DevTools\Commands\Builtin\Enumerate;
use Phalcon\DevTools\Commands\Builtin\Info;
use Phalcon\DevTools\Commands\Builtin\Migration;
use Phalcon\DevTools\Commands\Builtin\Model;
use Phalcon\DevTools\Commands\Builtin\Module;
use Phalcon\DevTools\Commands\Builtin\Project;
use Phalcon\DevTools\Commands\Builtin\Scaffold;
use Phalcon\DevTools\Commands\Builtin\Serve;
use Phalcon\DevTools\Commands\Builtin\Webtools;
use Phalcon\DevTools\Commands\CommandsListener;
use Phalcon\DevTools\Commands\DotPhalconMissingException;
use Phalcon\DevTools\Exception\PDODriverNotFoundException;
use Phalcon\DevTools\Script;
use Phalcon\DevTools\Script\Color;
use Phalcon\DevTools\Version;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Exception as PhalconException;
try {
require dirname(__FILE__) . '/bootstrap/autoload.php';
$vendor = sprintf('Phalcon DevTools (%s)', Version::get());
print PHP_EOL . Color::colorize($vendor, Color::FG_GREEN, Color::AT_BOLD) . PHP_EOL . PHP_EOL;
$eventsManager = new EventsManager();
$eventsManager->attach('command', new CommandsListener());
$script = new Script($eventsManager);
$commandsToEnable = [
Info::class,
Enumerate::class,
Controller::class,
Module::class,
Model::class,
AllModels::class,
Project::class,
Scaffold::class,
Migration::class,
Webtools::class,
Serve::class,
Console::class,
];
$script->loadUserScripts();
foreach ($commandsToEnable as $command) {
$script->attach(new $command($script, $eventsManager));
}
$script->run();
} catch (DotPhalconMissingException $e) {
fwrite(STDERR, Color::info($e->getMessage() . " " . $e->scanPathMessage()));
if ($e->promptResolution()) {
$script->run();
} else {
exit(1);
}
} catch (PhalconException $e) {
fwrite(STDERR, Color::error($e->getMessage()) . PHP_EOL);
exit(1);
} catch (PDODriverNotFoundException $e) {
$e->writeNicelyFormattedErrorOutput();
fwrite(STDERR, 'Backtrace:'. PHP_EOL);
fwrite(STDERR, $e->getTraceAsString() . PHP_EOL);
exit(1);
} catch (Exception $e) {
fwrite(STDERR, 'ERROR: ' . $e->getMessage() . PHP_EOL);
exit(1);
}