Gets the InputDefinition attached to this Command.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition | ||
return | Symfony\Component\Console\Input\InputDefinition | An InputDefinition instance |
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MyCommand extends Command { protected function configure() { $this ->setName('my:command') ->setDescription('My command description') ->addArgument('arg1', null, 'Argument 1') ->addOption('opt1', 'o', null, 'Option 1') ; } protected function execute(InputInterface $input, OutputInterface $output) { // do something } } // Get the definition of the MyCommand $cmd = new MyCommand(); $definition = $cmd->getDefinition();
use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; // Create a new Console Application $app = new Application(); // Get the definition of the "list" command $definition = $app->find('list')->getDefinition();In both examples, the Symfony Console Component library is being used.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition | ||
return | Symfony\Component\Console\Input\InputDefinition | An InputDefinition instance |