PHP code example of kentaro-a / phpcommander

1. Go to this page and download the library: Download kentaro-a/phpcommander 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/ */

    

kentaro-a / phpcommander example snippets


class EchoProcedure implements ProcedureInterface {
	public function __invoke(array $flgs=[]) {
		// Whatever you want.
		echo $flgs["param"] ."\n";
	}
}

$command_echo = new Command(
	"echo",
	new EchoProcedure(),
	new Flgs([$flg1]),
	"Simple echo parameter",
);

// Make instance.
$cli = new Commander($argv, [$command_echo]);

// you can also add other command by pushing into $commands or using add method like $cli->addCommand($command).

// Invoke procedure related on command name passed by $argv
$ret = $cli->invoke();

$ php batch.php

$ php batch.php echo -h(--help)