简体   繁体   English

Symfony控制台组件类别

[英]Symfony console component categories

Is there a way to put commands into a category for the Symfony Console component? 有没有办法将命令放入Symfony控制台组件的类别? Currently the commands are listed like so: 目前这些命令列出如下:

Available commands:
  create-droplets  Create droplets
  help             Displays help for a command
  list             Lists commands

What I would want is something like this: 我想要的是这样的:

Available commands:
  Server:
     create-droplets  Create droplets

  Default:
     help             Displays help for a command
     list             Lists commands

I think this is currently being done in Laravel with artisan but I am wondering if this is also possible with the Symfony Console component. 我认为目前正在Laravel中与工匠一起完成,但我想知道Symfony控制台组件是否也可以实现这一点。

Cheers. 干杯。

I recommend you to read about Symfony Console Commands: http://symfony.com/doc/current/console.html 我建议您阅读有关Symfony控制台命令的信息: http//symfony.com/doc/current/console.html

That being said, you can group commands. 话虽这么说,你可以分组命令。 Syntax: 句法:

group:command_name 组:COMMAND_NAME

In your case it would be: 在你的情况下,它将是:

  1. server:create-droplets 服务器:创液滴

    $this->setName('server:create-droplets') ->setDescription('Create droplets')

  2. default:help 默认:帮助

    $this->setName('default:help') ->setDescription('Displays help for a command')

  3. default:list 默认值:列表

    $this->setName('default:list') ->setDescription('Lists commands')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM