$ PHP 5.4.17 Development Server started at Mon Jan 13 15:35:03 2014 Listening on http://0:8080 Document root is /var/www Press Ctrl-‐C to quit. Docroot Router IP & port
readline("Where do you live: ");! echo PHP_EOL."Hello $name from $location\n"; $ php readline.php What's your name: Thijs Where do you live: Belgium ! Hello Thijs from Belgium $
! use Symfony\Component\Console\Application;! use Symfony\Component\Console\Command\Command;! use Symfony\Component\Console\Input\InputInterface;! use Symfony\Component\Console\Output\OutputInterface;! use Symfony\Component\Console\Input\InputArgument;! use Symfony\Component\Console\Input\InputOption;! ! $app = new Application('My CLI Application', '0.1.0');! $app->addCommands(array(! new Thijs\Console\Command\TestCommand()! ));! $app->run();
Symfony\Component\Console\Input\InputArgument;! use Symfony\Component\Console\Input\InputOption;! use Symfony\Component\Console\Formatter\OutputFormatterStyle;! ! class TestCommand extends Command {! } The command class
->addArgument('name',InputArgument::REQUIRED,'Your name')! ->addOption(! 'yell',! null,! InputOption::VALUE_NONE,! 'If set, the task will yell in uppercase letters'! )! ->setHelp('The <info>'.$this- >getName().'<info> command says hello to the world');! } Configure the command
action? [y/n]: y Who do you want to say hello to ?: PHP Continue with this action? [y/n]: y Who do you want to say hello to ?: ElePHPants Continue with this action? [y/n]: n Processing input Please wait 50/50 [============================] 100% +-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐+ | Hello | +-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐+ | Hello Thijs | | Hello PHP | | Hello ElePHPants | +-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐+