Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/macfja/symfony-console-filechooser
Filechooser Helper for Symfony console (with autocompletion support)
https://github.com/macfja/symfony-console-filechooser
autocomplete autocompletion chooser console file filesystem interactive symfony
Last synced: 2 months ago
JSON representation
Filechooser Helper for Symfony console (with autocompletion support)
- Host: GitHub
- URL: https://github.com/macfja/symfony-console-filechooser
- Owner: MacFJA
- License: mit
- Created: 2015-03-29T15:04:00.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-21T12:15:52.000Z (about 6 years ago)
- Last Synced: 2024-10-11T12:45:49.750Z (3 months ago)
- Topics: autocomplete, autocompletion, chooser, console, file, filesystem, interactive, symfony
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
File chooser
============The library provide a file selector capacity to any symfony console application.
It's support autocomplete functionality for navigating in directory.Installation
------------### Composer
```sh
composer require macfja/symfony-console-filechooser
```### Usage
```php
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();
```