简体   繁体   中英

Symfony console component categories

Is there a way to put commands into a category for the Symfony Console component? 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.

Cheers.

I recommend you to read about Symfony Console Commands: http://symfony.com/doc/current/console.html

That being said, you can group commands. Syntax:

group: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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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