Skip to content

Instantly share code, notes, and snippets.

@dcsg
Created January 9, 2014 14:19
Show Gist options
  • Save dcsg/8334789 to your computer and use it in GitHub Desktop.
Save dcsg/8334789 to your computer and use it in GitHub Desktop.
Code examples for my blog about the new feature for Symfony Console Component - set a default command
<?php
use Acme\Command\HelloWorldCommand;
use Symfony\Component\Console\Application;
$command = new HelloWorldCommand();
$application = new Application();
$application->add($command);
$application->setDefaultCommand($command->getName());
$application->run();
namespace Acme\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class HelloWorldCommand extends Command
{
protected function configure()
{
$this->setName('hello:world')
->setDescription('Outputs \'Hello World\'');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Hello World');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment