-
Notifications
You must be signed in to change notification settings - Fork 0
/
artisan
209 lines (166 loc) · 7.14 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
namespace App;
use App\config\App;
use App\config\Request;
class artisan
{
public function __construct($argv)
{
$dir = __DIR__;
$filename = $argv[array_key_last($argv)] ?? '';
# code...
if (
empty($argv[1])
) {
$this->run();
// error_reporting(E_ERROR);
}
foreach ($argv as $key) {
switch ($key) {
case 'migrate:refresh' :
$upd = 'down';
echo '------------rolling-----------' . PHP_EOL;
$ran = rand(0, 6);
for ($i = 0; $i < $ran; $i++) {
$dot = str_repeat('⛷', $i);
$this->log('💥rolling' . $dot) . PHP_EOL;
}
echo ' ------------DONE----------- ' . PHP_EOL;
// echo '.... DONE .....' . PHP_EOL;
require_once __DIR__ . "/config/migration/Migration.php";
break;
case 'migrate' :
$upd = 'up';
echo '------------ migrating -----------' . PHP_EOL;
$ran = rand(0, 6);
for ($i = 0; $i < $ran; $i++) {
$dot = str_repeat('🚣♂️', $i);
$this->log('💥migrating' . $dot) . PHP_EOL;
}
echo ' ------------DONE----------- ' . PHP_EOL;
require_once __DIR__ . "/config/migration/Migration.php";
break;
case 'make:controller':
$this->mcontroller ($filename);
break;
case 'del:controller':
echo "del";
$this->del($filename);
break;
case 'make:model' :
require_once __DIR__ . "/config/strings/controller/modal.php";
$controller = fopen(__DIR__ . '/App/models/' . $filename . '.php', 'wra', true);
if (fwrite($controller, $fileinfo)) {
$this->log("💥 $filename model successfully created 💯💯") . PHP_EOL;
}
break;
case 'make:migration':
require_once __DIR__ . "/config/strings/controller/migration.php";
$controller = fopen(__DIR__ . '/database/Migrations/' . lcfirst($filename) . '.php', 'wr', true);
if (fwrite($controller, $fileinfo)) {
$this->log("💥 $filename migration successfully created 💯💯") . PHP_EOL;
}
break;
default:
// $this->run();
break;
}
}
foreach ($argv as $key) {
switch ($key) {
case 'del:a':
$del = __DIR__ . "/App/Http/Controllers/" . $filename . ".php";
// $user_auth = shell_exec("sudo rm $del");
$io = __DIR__ . "/database/Migrations/" . $filename . ".php";
// $user_auth = shell_exec("sudo rm $del");
$cc = __DIR__ . "/App/models/" . $filename . ".php";
$user_auth = shell_exec("sudo rm $del $cc $io");
$this->log("💥 $filename controller successfully deleted 💯💯") . PHP_EOL;
if (
$user_auth
) {
$this->log("💥 $filename controller successfully deleted 💯💯") . PHP_EOL;
}
break;
case '-a':
$this->mcontroller ($filename,$hi ='Controller');
require_once __DIR__ . "/config/strings/controller/modal.php";
$controller = fopen(__DIR__ . '/App/models/' . $filename . '.php', 'wra', true);
if (fwrite($controller, $fileinfo)) {
$this->log("💥 $filename model successfully created 💯💯") . PHP_EOL;
}
require_once __DIR__ . "/config/strings/controller/migration.php";
$controller = fopen(__DIR__ . '/database/Migrations/' . lcfirst($filename) . '.php', 'wr', true);
if (fwrite($controller, $fileinfo)) {
$this->log("💥 $filename migration successfully created 💯💯") . PHP_EOL;
}
break;
default:
// $this->run();
break;
}
}
}
public function log($message)
{
echo "[" . date("Y-m-d H:i:s") . "] - " . $message . PHP_EOL;
}
public function run( )
{
$ran = rand(0, 6);
for ($i = 0; $i < $ran; $i++) {
$dot = str_repeat('🚀 ', $i);
$this->log('💥starting server ⛽🚀' . $dot) . PHP_EOL;
}
// error_reporting(E_ERROR | E_PARSE);
if (file_get_contents('http://localhost:8080/')) {
echo '🥺🥺 server is down dont worry trying another one' . PHP_EOL;
for ($i = 0; $i < 5; $i++) {
$ran = rand(0, 6);
for ($i = 0; $i < $ran; $i++) {
$dot = str_repeat('🚀 ', $i);
$this->log('💥starting server ⛽🚀' . $dot) . PHP_EOL;
}
shell_exec("php -S localhost:808$i -t public");
}
} else {
$this->log('💥 server 🚀 started successfully 💯💯' . $dot) . PHP_EOL;
echo '🥺🥺 server is down dont worry trying another one' . PHP_EOL;
for ($i = 0; $i < 5; $i++) {
$ran = rand(0, 6);
for ($i = 0; $i < $ran; $i++) {
$dot = str_repeat('🚀 ', $i);
$this->log('💥starting server ⛽🚀' . $dot) . PHP_EOL;
}
shell_exec("php -S localhost:808$i -t public");
}
}}
public function del($filename)
{
$del = __DIR__ . "/App/Http/Controllers/" . $filename . ".php";
$this->log("💥 $filename controller successfully deleted 💯💯") . PHP_EOL;
$user_auth = shell_exec("sudo rm $del");
if (
$user_auth
) {
$this->log("💥 $filename controller successfully deleted 💯💯") . PHP_EOL;
}
}
public function mcontroller($filename,$hi = '')
{
$filename = $filename . $hi;
require_once __DIR__ . "/config/strings/controller/controller.php";
$controller = fopen('App/Http/Controllers/' . $filename .'.php','a');
// fclose($controller);
// ejcho $fileinfo;
// j
// file_put_contents('App/Http/Controllers/' . $filename . '.php', $fileinfo);
if (
fwrite($controller, $fileinfo)
// file_put_contents('App/Http/Controllers/' . $filename . '.php', $contents)
) {
$this->log("💥 $filename controller successfully created 💯💯") . PHP_EOL;
}
}
}
new artisan($argv);