-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate.php
executable file
·62 lines (38 loc) · 1.99 KB
/
create.php
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
<?php
declare(strict_types=1);
$mvc_name_u = $argv[1];
$mvc_name_l = strtolower($argv[1]);
$win = false;
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$win = true;
} else {
}
$myfile = NULL;
$nl = "\n";
$tab = " ";
if($win){
$myfile = fopen("Models\\". $mvc_name_l. "_model.php", "w") or die("Unable to open file!");
}else{
$myfile = fopen("Models/". $mvc_name_l. "_model.php", "w") or die("Unable to open file!");
}
$txt = '<?php '.$nl.'declare(strict_types=1);'.$nl.$nl.$tab.'class '.$mvc_name_u.'Model extends Model'.$nl.$tab.'{'.$nl.$nl.$tab.$tab.'public function __construct()'.$nl.$tab.$tab.'{'.$nl.$tab.$tab.$tab.'$this->table_name = "'.$mvc_name_l.'s";'.$nl.$tab.$tab.$tab.'parent::__construct($this);'.$nl.$tab.$tab.'}'.$nl.$nl.$tab.'}';
fwrite($myfile, $txt);
fclose($myfile);
if($win){
$myfile = fopen("Views\\". $mvc_name_l. "_view.php", "w") or die("Unable to open file!");
}else{
$myfile = fopen("Views/". $mvc_name_l. "_view.php", "w") or die("Unable to open file!");
}
$txt = '<?php '.$nl.'declare(strict_types=1);'.$nl.$nl.$tab.'class '.$mvc_name_u.'View'.$nl.$tab.'{'.$nl.$nl.$tab.$tab.'private $controller;'.$nl.$tab.$tab.'private $model;'.$nl.$nl.$tab.$tab.'public function __construct($controller, $model)'.$nl.$tab.$tab.'{'.$nl.$tab.$tab.$tab;
$txt .= '$this->controller = $controller;'.$nl.$tab.$tab.$tab.'$this->model = $model;'.$nl.$tab.$tab.'}'.$nl.$nl.$tab.'}';
fwrite($myfile, $txt);
fclose($myfile);
if($win){
$myfile = fopen("Controllers\\". $mvc_name_l. "_controller.php", "w") or die("Unable to open file!");
}else{
$myfile = fopen("Controllers/". $mvc_name_l. "_controller.php", "w") or die("Unable to open file!");
}
$txt = '<?php '.$nl.'declare(strict_types=1);'.$nl.$nl.$tab.'class '.$mvc_name_u.'Controller'.$nl.$tab.'{'.$nl.$nl.$tab.$tab.'private $model;'.$nl.$nl.$tab.$tab.'public function __construct($model)'.$nl.$tab.$tab.'{'.$nl.$tab.$tab.$tab.'$this->model = $model;'.$nl.$tab.$tab.'}'.$nl.$nl.$tab.'}';
fwrite($myfile, $txt);
fclose($myfile);
?>