Magento 2 has a lot of console commands.
The console command can be of 2 types:
-
Embedded: they are added by the
\Magento\Setup\Console\CommandList::getCommandsClasses()
method. See the full embedded commands list. - Custom: they are added by the modules, including the standard modules (see examples below).
You can add and handle new commands with your custom module.
Let see as an example the cache:enable
core command.
It is declared by Mage_Backend
core module in di.xml
file:
It is implemented in \Magento\Backend\Console\Command\CacheEnableCommand
class.
Please note that a command must have a name set:
You must place the handling into the overriden execute
method: