-
Notifications
You must be signed in to change notification settings - Fork 2
/
smoothphp
executable file
·65 lines (53 loc) · 1.65 KB
/
smoothphp
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
#!/usr/bin/env php
<?php
/**
* SmoothPHP
* This file is part of the SmoothPHP project.
* **********
* Copyright © 2015-2020
* License: https://github.com/Ikkerens/SmoothPHP/blob/master/License.md
* **********
* smoothphp
*/
print('Initializing SmoothPHP CLI module.' . PHP_EOL);
set_time_limit(0);
define('__ENV__', 'cli');
$root;
if (file_exists(sprintf('%s/%s', getcwd(), 'smoothphp'))) {
$root = getcwd() . '/';
} else if (file_exists(file_exists(sprintf('%s/%s', __DIR__, 'smoothphp')))) {
$root = __DIR__ . '/';
} else {
$prts = explode('/', $argv[0]);
unset($prts[count($prts) - 1]);
if (file_exists(sprintf('%s/%s', implode('/', $prts), 'smoothphp')))
$root = realpath(implode('/', $prts)) . '/';
else
printf('Could not reliably determine __ROOT__.');
}
define('__ROOT__', str_replace('\\', '/', $root));
require_once __ROOT__ . 'framework/Bootstrap.php';
use SmoothPHP\Framework\Core\Kernel;
use SmoothPHP\Framework\Core\CLI as CLI;
$kernel = new Kernel();
$website = new Website();
$website->prepareClassloader($classLoader);
$website->initialize($kernel);
print('Finished initializing CLI module.' . PHP_EOL . '----' . PHP_EOL);
try {
/* @var CLI\Command */
$command = null;
if (isset($argv[1])) {
$cmdName = ucfirst(strtolower($argv[1]));
if (file_exists(__ROOT__ . 'framework/Core/CLI/' . $cmdName . '.php')) {
$className = 'SmoothPHP\\Framework\\Core\\CLI\\' . $cmdName;
$command = new $className();
}
}
if (!$command)
$command = new CLI\Help();
$command->handle($kernel, array_splice($argv, 2));
} catch (\RuntimeException $e) {
printf($e->getMessage());
}
print('----' . PHP_EOL . 'Closing SmoothPHP CLI module.' . PHP_EOL);