Skip to content

[Console] Document invokable command #20932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 7.3
Choose a base branch
from

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented May 1, 2025

Closes #20553

  • Make invokable commands first-class citizen
  • Move old command definition to a separate section

Pending docs to be updated:

  • components/console/console_arguments.rst (full refactoring required)
  • components/console/helpers/questionhelper.rst (full refactoring required)
  • console/input.rst (full refactoring required)
  • console.rst

Copy link
Contributor

@alamirault alamirault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the harmonization of some command names 👍

#[AsCommand(name: 'app:create-user')]
class CreateUserCommand
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should make all these changes with the #AsCommand attribute in a separate PR to avoid growing this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d actually prefer to keep all these related changes in a single PR, since they’re closely tied together. It helps keep the context in one place and makes it easier to review everything as a whole.

In any case, we can go ahead and merge this one, then open a new PR for the remaining updates.

@yceruto
Copy link
Member Author

yceruto commented May 5, 2025

Thanks @alamirault and @OskarStark for your review 🙏

I’m actively looking for someone to help me refactor console.rst, as I’m running out of free-time before the final release.

@94noni
Copy link
Contributor

94noni commented May 5, 2025

Pending docs to be updated:

I would also add https://symfony.com/doc/current/console/input.html, wdyt @yceruto ?
I can help on this in a separate unitary PR if its ok

@yceruto
Copy link
Member Author

yceruto commented May 5, 2025

Thanks, Antoine! Sure, go for it.

Here we're discussing input related topics symfony/symfony#59602

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yonel, thanks a lot for this massive contribution 🙇

I agree with what you said here:

we can go ahead and merge this one, then open a new PR for the remaining updates

I'll wait a bit to read more opinions, but that's the plan I'd like to follow. Thanks!

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with doing the work in steps, but I think the order should be swapped around.

We can't update all examples across the documentation to use features that we didn't document properly in my opinion. This applies in particular to console/input.rst, which has to be updated before we can start using #[Option]/#[Argument] in the documentation.
But it would be perfectly fine if all articles in the docs still have outdated (too complex) examples, but the main guides are updated to document both the simple + advanced way.

We must also be careful about updating an example without updating the context it is placed in (I tried to comment on those cases whenever I saw this).

@yceruto
Copy link
Member Author

yceruto commented May 13, 2025

Thanks @wouterj, @94noni, and @javiereguiluz for your feedback! I will try to address it ASAP

@yceruto yceruto force-pushed the invokable_command branch 5 times, most recently from 8b39fe4 to f638390 Compare May 28, 2025 21:50
@yceruto yceruto force-pushed the invokable_command branch 2 times, most recently from 2248692 to fd23b35 Compare May 28, 2025 21:57
@yceruto yceruto force-pushed the invokable_command branch from fd23b35 to 585684e Compare May 28, 2025 22:07
@yceruto
Copy link
Member Author

yceruto commented May 28, 2025

FYI, console.rst file is ready for review.

Working on console/input.rst...

@@ -472,7 +412,7 @@ command:
Note that it will not be called when the command is run without interaction
(e.g. when passing the ``--no-interaction`` global option flag).

:method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)*
``__invoke()`` *(required)*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute is still in Lifecycle I think

Suggested change
``__invoke()`` *(required)*
``__invoke()`` and :method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)*

What do you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console] Add support for invokable commands and input attributes
7 participants