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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
540
How AI agents are changing the way we should build APIs
fabpot
1
570
What is Symfony?
fabpot
1
240
Symfony in 2025: Scaling to 0
fabpot
3
810
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
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
340
Contextとはなにか
chiroruxx
1
390
Performance Engineering for Everyone
elenatanasoiu
0
270
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
240
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
580
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
290
AIエージェントで 変わるAndroid開発環境
takahirom
2
490
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
190
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
360
Featured
See All Featured
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
260
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
320
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Optimising Largest Contentful Paint
csswizardry
37
3.8k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
750
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
310
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