Add new console system
This commit is contained in:
38
console
Normal file
38
console
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
/**
|
||||
* Loading path constant
|
||||
*/
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('ROOT', dirname(__FILE__));
|
||||
|
||||
function findCommandClasses($directory)
|
||||
{
|
||||
$commandClasses = [];
|
||||
$files = glob($directory . '/*.php');
|
||||
foreach ($files as $file) {
|
||||
$commandClasses[] = basename($file, '.php');
|
||||
}
|
||||
return $commandClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable autoload
|
||||
*/
|
||||
require_once ROOT . DS . 'vendor'. DS . 'autoload.php';
|
||||
|
||||
$application = new Application();
|
||||
// Load all commands in Commands folder
|
||||
$command_directory = ROOT . DS . 'src' . DS . "Commands";
|
||||
$commandClasses = findCommandClasses($command_directory);
|
||||
foreach ($commandClasses as $commandClass) {
|
||||
$clsname = "App\\Commands\\$commandClass";
|
||||
$application->add(new $clsname());
|
||||
}
|
||||
$application->run();
|
||||
Reference in New Issue
Block a user