contao-community-alliance / console
CLI console application for Contao Open Source CMS
Package info
github.com/contao-community-alliance/console
Type:contao-module
pkg:composer/contao-community-alliance/console
1.0.1
2014-06-06 05:42 UTC
Requires
- php: >=5.3
- contao-community-alliance/composer-plugin: ~2.0
- contao-community-alliance/event-dispatcher: ~1.0
- contao/core: >=2.11,<4-dev
- symfony/console: ~2.3
Replaces
- bit3/contao-console: 1.0.1
This package is auto-updated.
Last update: 2026-03-06 12:29:42 UTC
README
Register you console command classes in $GLOBALS['CONSOLE_CMD'] within your config.php.
config.php
<?php
$GLOBALS['CONSOLE_CMD'][] = 'Acme\Command\GreetCommand';
GreetCommand.php
<?php
namespace = Acme\Command;
class GreetCommand extends \Symfony\Component\Console\Command\Command
{
protected function configure()
{
$this
->setName('demo:greet')
->setDescription('Greet someone')
->addArgument(
'name',
InputArgument::OPTIONAL,
'Who do you want to greet?'
)
->addOption(
'yell',
null,
InputOption::VALUE_NONE,
'If set, the task will yell in uppercase letters'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('name');
if ($name) {
$text = 'Hello '.$name;
} else {
$text = 'Hello';
}
if ($input->getOption('yell')) {
$text = strtoupper($text);
}
$output->writeln($text);
}
}
If you need a more complex setup routine, use the initializeConsole hook.
config.php
<?php
$GLOBALS['TL_HOOKS']['initializeConsole'][] = array('Acme\Console', 'myInitializeConsole');
Console.php
<?php
namespace Acme;
use Symfony\Component\Console\Application;
use Acme\Command\GreetCommand;
class Console
{
public function myInitializeConsole(Application $application)
{
$application->add(new GreetCommand());
}
}
For details see http://symfony.com/doc/2.3/components/console/introduction.html