- 
                Notifications
    You must be signed in to change notification settings 
- Fork 48
more features
        Inhere edited this page Feb 22, 2019 
        ·
        3 revisions
      
    - 在添加命令时,通过 $options设置命令(组)别名
- 也可以在你的命令类里面添加 aliases()方法,返回命令(组)别名,可以有多个。
    /**
     * @return array
     */
    public static function aliases(): array
    {
        return ['alias1', 'alias2'];
    }    /**
     * @return array
     */
    protected static function commandAliases(): array
    {
        return [
            // now, access 'home:i' is equals to 'home:index'
            'i'   => 'index', // for command indexCommand()
            'prg' => 'progress', // for command progressCommand()
		];
	}如果在这个group的多个子命令中有许多相同的命令选项。 此时,你可以为整个group添加公共选项,这些选项将会在每个命令的帮助信息里显示。
class MyController extend \Inhere\Console\Controller
{
	/**
     * @return array
     */
    protected function groupOptions(): array
    {
        return [
            '-c, --common' => 'This is a common option for all sub-commands',
        ];
    }
}相信在前面的文档中已经看到过类似:
 @usage {command} [arg ...] [--opt ...]
OR
 @usage {fullCommand} [arg ...] [--opt ...]其中的 {command} {fullCommand} 就是可替换变量,在渲染时,会被自动替换为对应的值。
- 方式一
protected function annotationVars(): array
{
     return \array_merge(parent::annotationVars(), [
         'myVar' => 'value',
     ]);
}- 方式二
在 init 方法里,调用 addAnnotationVar
    protected function init()
    {
        parent::init();
        $this->addAnnotationVar('myVar', 'value');
    }我的其他PHP项目
- inhere/kite 方便本地开发和使用的个人CLI工具应用
- php-toolkit/pflag PHP编写的,通用的命令行标志(选项和参数)解析库
- phppkg/easytpl 使用简单且快速的 PHP 模板引擎
- inhere/php-validate 一个简洁小巧且功能完善的php验证库
- inhere/sroute 轻量且快速的HTTP请求路由库