Modules : Commands
Commands use the helpfull console Symfony component. In your module you can define you own command that can be used with command CLI.
How to declare commands ?
In your config file :
<commands>
<command class="MyModule\Commands\HelloWorld"/>
</commands>
Create now a HelloWorld.php file in directory MyModule/Commands, and create a HelloWorld, which has to extend Thelia\Command\ContainerAwareCommand and implement at least the configure and execute methods.
For example :
<?php
namespace MyModule\Commands;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Command\ContainerAwareCommand;
class HelloWorld extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName("hello:world")
->setDescription("output hello world");
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("Hello world !");
}
}
You can now test the results using Thelia CLI tools. Go to your Thelia root directory and use this command :
$ php Thelia hello:world
Thelia uses all the features of the Symfony “command” component so you can refer to this component documentation to create your Thelia commands.