1. Go to this page and download the library: Download jjulien/php-cli-helper 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/ */
jjulien / php-cli-helper example snippets
#!/usr/bin/php
;
$helper = new Helper();
$helper->newOption()
->withName("file-in")
->withHelp("Input file to be processed")
->withShort("-i")
->withLong("--file-in")
->;
$helper->newOption()
->withName("verbose")
->boolean()
->withHelp("Display verbose output")
->withShort("v")
->withLong("verbose")
->build();
$helper->parse();
# Reading options
if ($helper->getValue('verbose')) {
print 'Reading in file "' . $helper->getValue('file-in') . '" and saving output to "' . $helper->getValue('file-out') . '"' . "\n";
}
#!/usr/bin/php
;
use CLIHelper\Option;
$helper = new Helper();
$option = new Option();
$option->setName("verbose");
$option->setShortOpt("-v");
$option->setLongOpt("--verbose");
$option->setType(Option::TYPE_BOOLEAN);
$option->setHelp("Display verbose output");
$helper->addOption($option);
$helper->parse();