-
Notifications
You must be signed in to change notification settings - Fork 2
/
run
96 lines (75 loc) · 2.32 KB
/
run
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
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env php
<?php
use Dotenv\Dotenv;
define('START_TIME', microtime(true));
// Enable handler
require_once(__DIR__.'/core/handler.php');
// Load Composer Packages
if(!is_file('/vendor/autoload.php')){
require_once(__DIR__ . '/vendor/autoload.php');
}else{
throw new Exception('composer not working');
}
// Load ENV values
if(!is_file('/.env')){
Dotenv::createImmutable(__DIR__)->load();
}else{
throw new Exception('.env file not found');
}
// Require Framework Core
require_once(__DIR__.'/core/core.php');
require_once('core/cli.php');
writeLn('');
writeLn('');
writeLn('----- Terminal start -----', ['bold', 'magentabg']);
writeLn('');
if (PHP_SAPI == "cli") {
parse_str($argv[1], $arg);
$option = $argv[1];
//writeLn($argv[1], ['green']);
if(!empty($option)){
if(strpos($option, ':')){
write('Command and Option: ');
writeLn($option, ['green']);
writeLn('');
$options = explode(':', $option);
$option = $options[0];
$suboption = $options[1];
switch($option){
case 'cache':
// Cache command
if($suboption == 'clear'){
$cache_path = realpath(__DIR__.'/storage/cache/views');
writeLn($cache_path);
(new File)->deleteDir($cache_path);
writeLn('Cache clear succesfully!');
}
break;
}
//print_r($options);
}else{
write('Command: ');
writeLn($option, ['green']);
writeLn('');
switch ($option){
case 'serve':
$command = "php -S ".env('APP_SERVE', "127.0.0.1").":".env('APP_SERVE_PORT', 8000)." index.php";
shell_exec($command);
break;
case 'optimize':
shell_exec('php run cache:clear');
writeLn('Cache clear');
break;
}
}
}
// Access argument values using getopt()
//print_r($option);
} else {
// Access argument values using $_GET etc.
}
writeLn('');
writeLn('----- Terminal end session -----', ['bold', 'magentabg']);
writeLn('');
writeLn('');
?>