-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli
executable file
·24 lines (20 loc) · 750 Bytes
/
cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env php
<?php
// Make sure this isn't being executed from somewhere else.
if (php_sapi_name() !== 'cli') {
echo "This script must be called from the command line" . PHP_EOL;
exit(1);
}
// Bootstrap.
require_once 'bootstrap.php';
// Determine the command classname, defaulting to 'help' if not found.
$commandName = isset($argv[1]) ? $argv[1] : 'help';
$commandClass = '\\App\\Commands\\' . ucfirst($commandName) . 'Command';
if (!class_exists($commandClass)) {
echo "ERROR: Command '$commandName' not valid." . PHP_EOL;
$commandClass = '\\App\\Commands\\HelpCommand';
}
// Remove the command itself from the argument list, and call the command.
array_shift($argv);
$command = new $commandClass($argv);
$command->run();