-
Notifications
You must be signed in to change notification settings - Fork 1
/
artisan
49 lines (41 loc) · 1.56 KB
/
artisan
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
<?php
if(!empty($_SERVER['argv'][1])){
//Create controller
if($_SERVER['argv'][1] == 'make:controller'){
if(!empty($_SERVER['argv'][2])){
//get controller name
$controllerName = $_SERVER['argv'][2];
//create controller
if(!file_exists('app/controllers/'.$controllerName.'.php')){
$data = '<?php
class '.$controllerName.' extends Controller{
public $data = [], $model = [];
public function __construct(){
//construct
}
public function index(){
//index
}
}';
file_put_contents('app/controllers/'.$controllerName.'.php', $data);
echo "\033[32mTạo controller $controllerName thành công\033[0m\n";
}else{
echo "Controller $controllerName đã tồn tại\033[0m\n";
}
}
}
//Delete controller
if($_SERVER['argv'][1] == 'delete:controller'){
if(!empty($_SERVER['argv'][2])){
//get controller name
$controllerName = $_SERVER['argv'][2];
//delete controller
if(file_exists('app/controllers/'.$controllerName.'.php')){
unlink('app/controllers/'.$controllerName.'.php');
echo "\033[32mXóa controller $controllerName thành công\033[0m\n";
}else{
echo "\033[31mController $controllerName không tồn tại\033[0m\n";
}
}
}
}