wiki/content/20201109141540-lazy_commands.md

765 B

id title
94e8a635-126e-4c26-8176-2020a5e79b26 Lazy Commands

Description

From Symfony 4.0 commands are lazily loaded. One broken command won't break all the other commands you have. In order to lazy-load a command do the following:

  • Define command as a service
  • Add a command property to the console.command tag

Syntax

app.command.complex_command:
  # ...
  tags:
    # the value of the 'command' attribute is the name of the command
    # (which is what the user needs to type in to execute it)
    - { name: console.command, command: app:my-command }

    # optionally you can define an alias for the command too
    - { name: console.command, command: app:my-command, alias: 'my-shortcut' }