I have an application with a Symfony Console based CLI. The application does not use the Symfony framework, just the Symfony Console component.
When I execute
php app/myapp
I get the usual overview with the name, version, options and registered commands shown. Suppose I just have one command, called "displaykittens". What I want to be able to do is
php app/myapp d <TAB>
And have it complete to
php app/myapp displaykittens
As is kinda expected in a modern unix environment. Unfortunately there appears to be no tab completion whatsoever. The Console Component itself provides an utility that allows doing something along these lines in commands themselves. That does not help me with getting tab completion for the commands though. Is this possible somehow?
Symfony 5.4+ has autocompletion natively.
You can get more information about autocompletion with bin/console completion --help.
For example with bash you can add this in your ~/.bashrc.
eval "$(/var/www/app/bin/console completion bash)"
Official announcement: https://symfony.com/blog/new-in-symfony-5-4-console-autocompletion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With