@@ -38,19 +38,6 @@ For example, you may want a command to create an user::
38
38
}
39
39
}
40
40
41
- If you're using the :ref: `default services.yml configuration <service-container-services-load-example >`,
42
- your command classes are automatically registered as services. You have nothing
43
- else to do!
44
-
45
- .. note ::
46
-
47
- You can also manually register your command as a service by configuring the service
48
- and :doc: `tagging it </service_container/tags >` with ``console.command ``.
49
-
50
- Symfony also looks in the ``Command/ `` directory of bundles for commands
51
- non registered as a service but this is deprecated since Symfony 3.4 and
52
- won't be supported in Symfony 4.0.
53
-
54
41
Configuring the Command
55
42
-----------------------
56
43
@@ -77,12 +64,26 @@ method. Then you can optionally define a help message and the
77
64
Executing the Command
78
65
---------------------
79
66
80
- After configuring the command, you can execute it in the terminal:
67
+ Symfony registers any PHP class extending from :class: `Symfony\C omponent\C onsole\C ommand\C ommand `
68
+ as a console command automatically, so you can now execute this command in the
69
+ terminal:
81
70
82
71
.. code-block :: terminal
83
72
84
73
$ php bin/console app:create-user
85
74
75
+ .. note ::
76
+
77
+ If you're using the :ref: `default services.yml configuration <service-container-services-load-example >`,
78
+ your command classes are automatically registered as services.
79
+
80
+ You can also manually register your command as a service by configuring the service
81
+ and :doc: `tagging it </service_container/tags >` with ``console.command ``.
82
+
83
+ Otherwise, Symfony looks in the ``Command/ `` directory of bundles for commands
84
+ non registered as a service but this is deprecated since Symfony 3.4 and
85
+ won't be supported in Symfony 4.0.
86
+
86
87
As you might expect, this command will do nothing as you didn't write any logic
87
88
yet. Add your own logic inside the ``execute() `` method, which has access to the
88
89
input stream (e.g. options and arguments) and the output stream (to write
0 commit comments