PHP code example of virge / cli

1. Go to this page and download the library: Download virge/cli library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

virge / cli example snippets




use Virge\Cli;
use Virge\Cli\Component\{
    Command,
    Input
};

class MyCommand extends Command
{
    const COMMAND = 'my_command';
    const COMMAND_HELP = 'some help text';
    const COMMAND_USAGE = 'my_command [--someOption] arg1';

    public function run(Input $input)
    {
        if($input->getOption('someOption')) {
            Cli::success("Something worked!");
        } else {
            Cli::error("Oops");
        }
    }
}

Cli::add(MyCommand::COMMAND, MyCommand::class)
->setHelpText(MyCommand::COMMAND_HELP)
->setUsage(MyCommand::COMMAND_USAGE)
;