2024-05-06 20:40:05 +00:00
|
|
|
---
|
2024-10-29 18:27:12 +00:00
|
|
|
date: 2020-11-09
|
2024-05-06 20:40:05 +00:00
|
|
|
id: 94e8a635-126e-4c26-8176-2020a5e79b26
|
|
|
|
title: Lazy Commands
|
|
|
|
---
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
|
|
|
From [Symfony 4.0](20201109140137-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
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
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' }
|
|
|
|
```
|