macfja / symfony-console-filechooser
Filechooser Helper for Symfony console (with autocompletion support)
Installs: 12 457
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- hoa/file: ~1
- symfony/console: ~2.6 || ^3.0 || ^4.0
This package is auto-updated.
Last update: 2024-12-22 02:16:55 UTC
README
The library provide a file selector capacity to any symfony console application. It's support autocomplete functionality for navigating in directory.
Installation
Composer
composer require macfja/symfony-console-filechooser
Usage
use MacFJA\Symfony\Console\Filechooser\FilechooserHelper; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; $app = new Application(); // Adding the helper to Symfony Console Application $app->getHelperSet()->set(new FilechooserHelper()); $app->register('ask-path')->setCode(function (InputInterface $input, OutputInterface $output) use ($app) { // ask and validate the answer $dialog = $app->getHelperSet()->get('filechooser'); $filter = new \MacFJA\Symfony\Console\Filechooser\FileFilter('Where is your file? '); $path = $dialog->ask($input, $output, $filter); $output->writeln(sprintf('You have just entered: %s', $path)); }); $app->run();