Skip to content

Instantly share code, notes, and snippets.

@dcsg
Created January 9, 2014 14:19
Show Gist options
  • Select an option

  • Save dcsg/8334789 to your computer and use it in GitHub Desktop.

Select an option

Save dcsg/8334789 to your computer and use it in GitHub Desktop.

Revisions

  1. Daniel Gomes created this gist Jan 9, 2014.
    19 changes: 19 additions & 0 deletions HelloWorldCommand.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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');
    }
    }
    10 changes: 10 additions & 0 deletions app.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?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();