Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SymfonyCon 2013 Lightning Talk about the Consol...
Search
Fabien Potencier
December 13, 2013
Programming
1.3k
10
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SymfonyCon 2013 Lightning Talk about the Console in 2.5
Fabien Potencier
December 13, 2013
More Decks by Fabien Potencier
See All by Fabien Potencier
20 years of Symfony, what's next?
fabpot
2
530
How AI agents are changing the way we should build APIs
fabpot
1
560
What is Symfony?
fabpot
1
240
Symfony in 2025: Scaling to 0
fabpot
3
800
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
4
1.8k
Using some Git magic on the Symfony mono-repository
fabpot
1
360
Using some Git magic on the Symfony mono-repository
fabpot
1
550
The Symfony Terminal Component
fabpot
2
1.3k
Out-of-band activities, the Scheduler component
fabpot
3
520
Other Decks in Programming
See All in Programming
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
120
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
A2UI という光を覗いてみる
satohjohn
1
140
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
130
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
130
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
340
Claspは野良GASの夢をみるか
takter00
0
190
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.6k
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
4 Signs Your Business is Dying
shpigford
187
22k
Site-Speed That Sticks
csswizardry
13
1.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Transcript
Easier interaction with the user from a Console application https://secure.flickr.com/photos/sylvain_masson/4195880838
?hidden answer limited choices validator yes/no question autocompleter number of
aempts default value multiple values
ask() select() askConfirmation() askAndValidate() askHiddenResponse() AskHiddenResponseAndValidate()
select ask askConfirmation askHiddenResponse AskAndValidate askHiddenResponseAn dValidate aempts Y Y
Y Y hidden answer Y Y autocompleter Y Y validator Y Y Y default value Y Y Y Y yes/no Y choices Y
AskAQuestionWithALimitedSe tOfChoicesButLetTheUserPro videAFreeTextAnswerIfHeWan tsToButOfCourseHideTheResp onseAndPleaseValidateTheAn swerInAWayThatEmptyReturns APredefinedDefaultValue()
From the Dialog Helper to the Question Helper 2.5
QuestionHelper::ask( OutputInterface $output, Question $question )
use Symfony\Component\Console\Dialog\Question; $helper = $this->getHelper('question'); $question = new Question('Enter your
full name: '); $name = $helper->ask($output, $question);
$question = new Question('Enter your full name: ', 'me');
$question->setHidden(true);
$question->setAutocompleter(array('one', 'two', '...'));
$question->setMaxAttemps(5);
$question->setValidator(function ($value) { if (!empty($value)) { return $value; } throw
new \InvalidArgumentException( 'You need to provide a non-empty value.'); });
$question = new ChoiceQuestion('Choose a color', array('red', 'blue'), 'blue'); $question->setMultiselect(true);
$question->setPrompt(' > '); $question->setErrorMessage("That's not a valid color!");
new ConfirmationQuestion('Is it better?', true); 2.5
Better feedback when running external processes from a Console application
https://secure.flickr.com/photos/petergorges/3052698754
$process = new Process('ls -lsa'); $process->run(); $output->writeln($process->getOutput());
$callback = function ($type, $buffer) use ($output) { $output->write($buffer); };
$process->run(OutputInterface::VERBOSITY_VERBOSE < $output- >getVerbosity() ? $callback : null);
$callback = function ($type, $buffer) use ($output, &$startedOut, &$startedErr) {
if ('err' === $type) { if (!$startedErr) { $output->write("\n<bg=red;fg=white> ERR </> "); $startedErr = true; $startedOut = false; } $output->write(str_replace("\n", "\n<bg=red;fg=white> ERR </> ", $buffer)); } else { if (!$startedOut) { $output->write("\n<bg=green;fg=white> OUT </> "); $startedOut = true; $startedErr = false; } $output->write(str_replace("\n", "\n<bg=green;fg=white> OUT </> ", $buffer)); } };
None
$helper = $this->getHelper('process'); $process = $helper->run($output, 'ls -lsa'); $output->writeln($process->getOutput()); 2.5
$helper->run($output, 'ls -lsa'); $helper->run($output, 'run foobar'); ./app/console ... -vv
$helper->run($output, 'ls -lsa'); ./app/console ... -vvv
./app/console ... -vvv $helper->run($output, 'run foobar');
$helper = $this->getHelper('process'); $process = new Process('ls -lsa'); $helper->run($output, $process);
$output->writeln($process->getOutput()); 2.5
$callback = function ($type, $buffer) { error_log($buffer); }; $helper->run($output, $process,
null, $callback); 2.5
What about debugging HTTP requests?
use Guzzle\Http\Client; $client->get('http://example.com/')->send();
use Guzzle\Http\Client; $client = new Client(); $client->addSubscriber(new GuzzleConsolePlugin( $output, $this->getHelper('debug_formatter'))
); $client->get('http://example.com/')->send(); 2.5
./app/console ... -vv $client->get('http://example.com/')->send(); $client->get('http://symfony.com/foobar')->send();
./app/console ... -vv $client->get('http://insight.sensiolabs.com/')->send();
None
$formatter = $this->getHelperSet()->get('debug_formatter'); // start a session $start = $formatter->start($uuid,
$cmd); $output->write($start); // give some feedback $progress = $formatter->progress($uuid, $buffer, $isError); $output->write($progress); // at the end $stop = $formatter->stop($uuid, $message, $isSuccessful); $output->write($stop); 2.5