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
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
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
130
Creating Composable Callables in Contemporary C++
rollbear
0
170
Oxcを導入して開発体験が向上した話
yug1224
4
350
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
130
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
330
Agentic UI
manfredsteyer
PRO
0
200
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.6k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
980
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
370
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Building an army of robots
kneath
306
46k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
4 Signs Your Business is Dying
shpigford
187
22k
The Limits of Empathy - UXLibs8
cassininazir
1
370
The Cost Of JavaScript in 2023
addyosmani
55
10k
Leo the Paperboy
mayatellez
7
1.9k
The Language of Interfaces
destraynor
162
27k
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