Gets the InputDefinition related to this Application.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition | ||
return | Symfony\Component\Console\Input\InputDefinition | The InputDefinition instance |
use Symfony\Component\Console\Application; $application = new Application(); $definition = $application->getDefinition(); // $definition will now contain an array of all commands and their arguments/options
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; class MyCommand extends Command { protected function configure() { $this->setName('mycommand') ->setDescription('Example command'); $this->addArgument('arg1', InputArgument::REQUIRED, 'Argument 1'); $this->addOption('option1', 'o', InputOption::VALUE_NONE, 'Option 1'); } } $application = new Application(); $application->add(new MyCommand()); $definition = $application->getDefinition(); // $definition will now contain an array with the 'mycommand' command and its argument(s)/option(s)In this example, we create a custom command `MyCommand` with an argument and an option, and then add it to the application. We then retrieve the application's definition, which will now include our custom command. Overall, the `getDefinition` method is useful when you need to inspect the commands/arguments/options of an application at runtime. This method is part of the Symfony Console Component.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition | ||
return | Symfony\Component\Console\Input\InputDefinition | The InputDefinition instance |