Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active July 13, 2022 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mficzel/da4b29cf11dc0e60881133fa4510f37d to your computer and use it in GitHub Desktop.
Save mficzel/da4b29cf11dc0e60881133fa4510f37d to your computer and use it in GitHub Desktop.
Use Symfony console helper for selection with autocomplete
# @see https://symfony.com/doc/current/components/console/helpers/questionhelper.html
$bundles = ['AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle'];
$question = new Question('Please enter the name of a bundle: ', 'FooBundle');
$question->setAutocompleterValues($bundles);
$input = new SymfonyStringInput('');
$output = new SymfonyConsoleOutput();
$helper = new QuestionHelper();
$result = $helper->ask($input, $output, $question);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment