An example of extending TYPO3 Console 4.x with a custom command controller.
The custom command controller must extend Helhum\Typo3Console\Mvc\Controller\CommandController
and implement at least one public method containing the custom code, with a method name ending
in 'Command':
class HelloCommandController extends \Helhum\Typo3Console\Mvc\Controller\CommandController
public function helloWorldCommand() {}
Before being ready to be used, the custom command controller needs to be registered in
TYPO3 Console. This is done in a configuration file located at Configuration/Console/Commands.php
,
returning an array of configuration keys/vaues.
'controllers' => [
Srotsch\HelloT3console\Command\HelloCommandController::class
],
In case the custom command does not require TYPO3 to be set up in order to run, e.g. if it does not require a database connection, it can be made available in the initial command set of TYPO3 Console by defining a RunLevel.
'runLevels' => [
'hello_t3console:hello:helloworld' => \Helhum\Typo3Console\Core\Booting\RunLevel::LEVEL_COMPILE
],
$ git clone https://github.com/srotsch/hello-t3console.git
$ cd hello-t3console
$ composer install
$ vendor/bin/typo3cms hello:helloworld
Hello, world!