-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbasic
48 lines (37 loc) · 1000 Bytes
/
basic
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
#!/usr/bin/env php
<?php
// Basic CLI actions for PHP Mini Framework
require __DIR__ . '/vendor/autoload.php';
use App\Core\CLI;
$cli = new CLI();
//print_r($argc); // number or arguments
//print_r($argv);
$command = $argv[1];
// serve the site
if ($command == 'serve') {
print_r(getcwd());
$oldPath = getcwd();
chdir(getcwd() . '\public');
$output = shell_exec('php -S 127.0.0.1:8000');
chdir($oldPath);
print_r($output);
}
// Create a certain file type
else if (strpos($command, 'new:') !== false && isset($argv[2])) {
$commandParts = explode(':', $command);
$makeThis = $commandParts[1];
// Create a controller
if ($makeThis == 'controller') {
$controllerName = $argv[2];
$cli->createController($controllerName);
}
// Create a model
if ($makeThis == 'model') {
$modelName = $argv[2];
$cli->createModel($modelName);
}
} else {
print_r("Not a valid Basic Framework command.");
}
echo "\n";
die();