$input = new ArgvInput(); if ($input->hasOption('verbose')) { // do something if verbose option is set }
$options = array( new InputOption('debug', null, InputOption::VALUE_NONE, 'Enable debugging mode.'), new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Set the timeout (in seconds).', 30), ); $input = new ArrayInput(array(), $options); if ($input->hasOption('timeout')) { $timeout = $input->getOption('timeout'); // do something with timeout option }In this example, we create an array of options using the InputOption class. We then create a new instance of the ArrayInput (which also implements InputInterface) with these options. We check if the "timeout" option is set using the hasOption method, and then retrieve its value using the getOption method. The Symfony Console Component is a package library within the Symfony PHP Framework.