bamarni/symfony-console-autocomplete
Composer 安装命令:
composer require bamarni/symfony-console-autocomplete
包简介
Shell completion for Symfony Console based scripts
README 文档
README
Enables shell autocompletion for tools based on the Symfony Console (Symfony framework, Composer, PHPSpec, Behat, etc.)
Prerequisites
- Make sure the global composer project is configured properly with your shell. Notably, the composer global bin directory needs to be in your path. See https://getcomposer.org/doc/03-cli.md#global for instructions on how todo that.
- If you're using bash, you'll have to make sure programmable completion functions are available. Linux distributions usually ship it and enable it by default. On Mac OSX, you can install it with brew (
brew install bash-completion) and enable it by addingsource $(brew --prefix)/etc/bash_completionat the end of your.bashrc.
Installation
Install the tool globally with Composer :
composer global require bamarni/symfony-console-autocomplete
Quick setup
Add the following line at the end of your shell configuration file (~/.bash_profile or ~/.zshrc) :
eval "$(symfony-autocomplete)"
Close / re-open your terminal window and you're ready to go!
Note that quick setup only works for supported tools.
Static setup
If you don't like all the magic from the quick setup and want to go with a more standard way, you can dump a static completion file for a given tool :
symfony-autocomplete composer
This will print the completion script for Composer to stdout. The output should be saved at a specific location depending on your OS / setup. Here are a few examples :
# BASH - Ubuntu / Debian
symfony-autocomplete composer | sudo tee /etc/bash_completion.d/composer
# BASH - Mac OSX (with Homebrew "bash-completion")
symfony-autocomplete composer > $(brew --prefix)/etc/bash_completion.d/composer
# ZSH - Config file
symfony-autocomplete composer > ~/.composer_completion && echo "source ~/.composer_completion" >> ~/.zshrc
# FISH
symfony-autocomplete --shell=fish composer > ~/.config/fish/completions/composer.fish
If you are running an environment that does not have automatic execution of PHP scripts, then you will need to call PHP and the script in question :
symfony-autocomplete "php ./artisan"
General tips
Update
To update the tool to a new version use :
composer global update bamarni/symfony-console-autocomplete
Symfony framework completion
In order to get completion running, you shouldn't prepend php at the beginning of the command :
app/console [TAB]
Tips for Bash users
Alias support
By default, completion for your aliases won't be enabled. If you're using aliases (e.g. "c" for "composer", "pspec" for "phpspec", etc.), you have to pass them explicitly :
symfony-autocomplete --aliases=c --aliases=pspec
Tips for Docker users
Defining the SHELL environment variable
If you connect to your container using something similar to docker exec -it container bash then
you may find that the completions cannot be built due to an inability to locate the SHELL
environment variable. This has been reported in #32
A solution is to supply the SHELL environment variable as part of the docker exec command:
docker exec -e SHELL=bash -it container bash
Supported tools
All tools using the Symfony Console component are supported.
However, quick setup only works if the entrypoint is named console or in the following list of tools:
bamarni/symfony-console-autocomplete 适用场景与选型建议
bamarni/symfony-console-autocomplete 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 451.73k 次下载、GitHub Stars 达 490, 最近一次更新时间为 2013 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bamarni/symfony-console-autocomplete 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bamarni/symfony-console-autocomplete 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 451.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 494
- 点击次数: 32
- 依赖项目数: 2
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2013-01-13
