Gets the default commands that should always be available.
protected getDefaultCommands ( ) : |
||
return | An array of default Command instances |
use Symfony\Component\Console\Application; $application = new Application(); $defaultCommands = $application->getDefaultCommands(); foreach ($defaultCommands as $command) { echo $command->getName() . "\n"; }
use Symfony\Component\Console\Command\Command; $application = new Application(); $defaultCommands = $application->getDefaultCommands(); // Add a new command to the application $newCommand = new Command('my:command'); $application->add($newCommand); // Print all commands $commands = $application->all(); foreach ($commands as $command) { echo $command->getName() . "\n"; }This example creates a new `Command` instance with the name `my:command` and adds it to the `Application` using the `add()` method. Then, it prints out all the commands in the application, including the newly added one. The Symfony Console component is often used in combination with other Symfony components and packages to create fully featured console applications in PHP.
protected getDefaultCommands ( ) : |
||
return | An array of default Command instances |