Registering Commands
Registering Commands Automatically
To make the console commands available automatically within a Drupal installation, you will need to:
Create a
Commanddirectory inside your module i.e.src/Commandand create aPHPfile suffixed withCommand.phpi.e.MyCustomCommand.phpfor each command that you want to provide.Make sure you class extends one of
CommandorContainerAwareCommandclasses.
Drupal Console provides two types of commands, stand alone and container aware commands.
Stand alone commands
These commands are listed and can run outside of a Drupal installation, you defined one by extending the Command class.
use Drupal\Console\Command\Command;
class MyStandAloneCommand extends Command
{
}
Container aware commands
These commands are listed and must be run against a Drupal, you defined one by extending the ContainerAwareCommand class.
use Drupal\Console\Command\ContainerAwareCommand;
class MyContainerAwareCommand extends ContainerAwareCommand
{
}