I'm creating a PHP CLI, and wanted to run something like this
php console.php comando -a foo -b bar -d
But with the function getopt
I can not pass comando
if not the buga function and I do not receive any of the other arguments. I need to set a default parameter to -c
:
php console.php -c comando -a foo -b bar -d
Does anyone know of any method to "parse" the arguments ignoring the first?
PS: I also need to get the first argument, to know which command to execute.
public function run() {
$command = $this->getCommand();
if (is_null($command)) return FALSE;
$optcll = $command->getOptionCollection();
$opts = $optcll->dump();
// LINHA QUE PEGO OS ARGUMENTOS DO COMANDO
$args = getopt($opts['options'], $opts['longopts']);
return $command->execute($this, $args);
}