programs/CLI.php
public function run($argv)
    {
        $PHP = $this->CONFIG;

        // I do this so the I can pass the argvs correctly to the php executables
        print "\nIt's a powerful " . array_shift($argv) . ", hu?\n\n";

        $program = strtolower(array_shift($argv));

        foreach ($this->programs as $name) {
            // I prefer this loop so I catch
            if ($program !== $name) {
                continue;
            }

            /** @noinspection PhpIncludeInspection */
            if (false === include $name . '.php') {
                die('Failed loading file "' . $name . '.php". Please no syntax errors exist in this file.');
            }

            $classes = get_declared_classes();

            $class = end($classes);

            if (!class_exists($class)) {
                die('Failed to load the class ("' . $class . '")');
            }

            $imp = class_implements($class);

            if (!array_key_exists(iCommand::class, $imp)) {
                die('The program class should also implement iCommand. '. print_r($imp, true));
            }

            // We're only using this closure to reinforce our iCommand // type hint
            $run = function (iCommand $cmd) use ($argv) {
                return $cmd->run($argv) and $cmd->cleanUp($argv);
            };

            exit($run(new $class($PHP)));
        }

        switch ($program) {
            case 'minify':
                    print "\n\nminify\n\n";
                break;
            case 'check':
                $cmd = 'netstat -a -n -o | find "' . ($PHP['SOCKET']['PORT'] ?? 8888) . '\"';
                print PHP_EOL . $cmd . PHP_EOL;
                print shell_exec($cmd);
                break;
            case 'test':
                print PHP_EOL;
                print shell_exec('phpunit --bootstrap vendor/autoload.php --testdox  tests');
                print PHP_EOL;
                break;
            case 'php':
                print 'Starting PHP Websocket' . PHP_EOL;
                $CMD = 'php ' . CARBON_ROOT . 'Server.php ' . APP_ROOT . ' ' . $PHP['SITE']['CONFIG'];
                print `$CMD`;
                break;
            case 'help':
            default:
                $this->usage();
        }
        return 0;
    }
public function run($argv)
    {
        $PHP = $this->CONFIG;

        // I do this so the I can pass the argvs correctly to the php executables
        print "\nIt's a powerful " . array_shift($argv) . ", hu?\n\n";

        $program = strtolower(array_shift($argv));

        foreach ($this->programs as $name) {
            // I prefer this loop so I catch
            if ($program !== $name) {
                continue;
            }

            /** @noinspection PhpIncludeInspection */
            if (false === include $name . '.php') {
                die('Failed loading file "' . $name . '.php". Please no syntax errors exist in this file.');
            }

            $classes = get_declared_classes();

            $class = end($classes);

            if (!class_exists($class)) {
                die('Failed to load the class ("' . $class . '")');
            }

            $imp = class_implements($class);

            if (!array_key_exists(iCommand::class, $imp)) {
                die('The program class should also implement iCommand. '. print_r($imp, true));
            }

            // We're only using this closure to reinforce our iCommand // type hint
            $run = function (iCommand $cmd) use ($argv) {
                return $cmd->run($argv) and $cmd->cleanUp($argv);
            };

            exit($run(new $class($PHP)));
        }

        switch ($program) {
            case 'minify':
                    print "\n\nminify\n\n";
                break;
            case 'check':
                $cmd = 'netstat -a -n -o | find "' . ($PHP['SOCKET']['PORT'] ?? 8888) . '\"';
                print PHP_EOL . $cmd . PHP_EOL;
                print shell_exec($cmd);
                break;
            case 'test':
                print PHP_EOL;
                print shell_exec('phpunit --bootstrap vendor/autoload.php --testdox  tests');
                print PHP_EOL;
                break;
            case 'php':
                print 'Starting PHP Websocket' . PHP_EOL;
                $CMD = 'php ' . CARBON_ROOT . 'Server.php ' . APP_ROOT . ' ' . $PHP['SITE']['CONFIG'];
                print `$CMD`;
                break;
            case 'help':
            default:
                $this->usage();
        }
        return 0;
    }
Command Line Interface. Use
I pass the php array to this function
for reporting purposes.
php index.php [command]
@param $argv
@return mixed