Skip to content

Instantly share code, notes, and snippets.

@DuffleOne
Created January 3, 2015 12:46
Show Gist options
  • Save DuffleOne/659617c9fc24337d96e8 to your computer and use it in GitHub Desktop.
Save DuffleOne/659617c9fc24337d96e8 to your computer and use it in GitHub Desktop.
Example Symfony Console Command with CLImate
#! /usr/bin/env php
<?php
require_once 'vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use League\CLImate\CLImate;
$app = new Application('Duffleman Test', '1.0');
$app->register('sayHelloTo')
->setDescription('Offer a greeting')
->addArgument('name', InputArgument::REQUIRED, 'Your name')
->setCode(function(InputInterface $input, OutputInterface $output) {
$cli = new CLImate;
$name = $input->getArgument('name');
$output->writeln('Hello ' . $name);
$cli->red('Hello ' . $name);
});
$app->run();
@mosiyash
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment