Gets the default input definition.
protected getDefaultInputDefinition ( ) : Symfony\Component\Console\Input\InputDefinition | ||
return | Symfony\Component\Console\Input\InputDefinition | An InputDefinition instance |
use Symfony\Component\Console\Application; $app = new Application(); $inputDefinition = $app->getDefaultInputDefinition(); // Print all the options and arguments foreach ($inputDefinition->getOptions() as $option) { echo $option->getName() . "\n"; } foreach ($inputDefinition->getArguments() as $argument) { echo $argument->getName() . "\n"; }
use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputOption; $app = new Application(); $app->getDefinition()->addOption(new InputOption('--debug', '-d', InputOption::VALUE_NONE, 'Enable debugging')); $inputDefinition = $app->getDefaultInputDefinition(); // Print all the options and arguments foreach ($inputDefinition->getOptions() as $option) { echo $option->getName() . "\n"; }In this example, we are creating a new application object and adding a new option to it using the addOption method. This option enables debugging and has a short name (-d) and a long name (--debug). Then we are calling the getDefaultInputDefinition method to get the input definition, and we are printing all the options that the app accepts. In both examples, we are using the Symfony Console component to build command-line applications in PHP.
protected getDefaultInputDefinition ( ) : Symfony\Component\Console\Input\InputDefinition | ||
return | Symfony\Component\Console\Input\InputDefinition | An InputDefinition instance |