1. Go to this page and download the library: Download nerou/cli-parser 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/ */
nerou / cli-parser example snippets
if(PHP_SAPI !== 'cli' || !isset($_SERVER['argv'])){
exit(1); // exit if not run via CLI
}
$cliArgs = new CLIParser($_SERVER['argv']);
$cliArgs->setAllowedOptions(['foo', 'bar']); // list of supported options
$cliArgs->setAllowedFlags(['f' => 'foo']); // maps flags to options
$cliArgs->setStrictMode(true); // parse() will return `false` if there are options/flags that are not allowed
if(!$cliArgs->parse()){
printUsage(); // show them how to use this script
exit(1);
}