PHP code example of leaveyou / console
1. Go to this page and download the library: Download leaveyou/console 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/ */
leaveyou / console example snippets
/** class importing */
use Leaveyou\Console\Input;
use Leaveyou\Console\Parameter;
use Leaveyou\Console\ParameterSet;
use Leaveyou\Console\Tools\CommandLineParser;
use Leaveyou\Console\Tools\Help;
use Leaveyou\Console\Tools\ResultNormalizer;
/** composer autoloader */
meter("simple");
$complexParameter = Parameter::create("complex")
->setType(Parameter::TYPE_MANDATORY)
->setDescription("Some example of a complex parameter")
->setShortName('c')
->setValueType(Parameter::VALUE_STRING);
/** Inject parameters */
$consoleInput->addParameter($simpleParameter);
$consoleInput->addParameter($complexParameter);
/** Read parameters */
$simple = $consoleInput->getValue('simple');
$complex = $consoleInput->getValue('complex');
test.php --simple="sure thing" --complex "yes" --complex "no"