From 0d7514c2d55207066b1f2719b5e104668e09349f Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Fri, 22 Aug 2025 09:49:31 -0400 Subject: [PATCH 1/2] Document that usages may be supplied by AsCommand Attribute --- console.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/console.rst b/console.rst index a9457c1620f..361984066fb 100644 --- a/console.rst +++ b/console.rst @@ -147,12 +147,13 @@ If you can't use PHP attributes, register the command as a service and :ref:`default services.yaml configuration `, this is already done for you, thanks to :ref:`autoconfiguration `. -You can also use ``#[AsCommand]`` to add a description and longer help text for the command:: +You can also use ``#[AsCommand]`` to add a description, usages, and longer help text for the command:: #[AsCommand( name: 'app:create-user', description: 'Creates a new user.', // the command description shown when running "php bin/console list" help: 'This command allows you to create a user...', // the command help shown when running the command with the "--help" option + usages: ['app:create-user alice'], )] class CreateUserCommand { From 21ee0fc80dc2fdf9abb9da5bbe2808db49180392 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Wed, 27 Aug 2025 16:02:07 -0400 Subject: [PATCH 2/2] Add versionadded directive --- console.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/console.rst b/console.rst index 361984066fb..7f581ff7c79 100644 --- a/console.rst +++ b/console.rst @@ -163,6 +163,10 @@ You can also use ``#[AsCommand]`` to add a description, usages, and longer help } } +.. versionadded:: 7.4 + + The ability to add usages via a ``$usages`` property was introduced in Symfony 7.4. + Additionally, you can extend the :class:`Symfony\\Component\\Console\\Command\\Command` class to leverage advanced features like lifecycle hooks (e.g. :method:`Symfony\\Component\\Console\\Command\\Command::initialize` and and :method:`Symfony\\Component\\Console\\Command\\Command::interact`)::