Skip to content

Clarify the Console command "lifecycle methods" #4996

Closed
@wouterj

Description

@wouterj

Commands have 3 lifecycle methods:

  • initialize($input, $output)
  • interact($input, $output)
  • execute($input, $output)

At first, they might seem redundant and the docs doesn't tell a lot about the difference between them. It turns out interact() is called before the validation of the input definition. This means that this is the only place where the command can interactively ask for values of missing options. executes() contains the logic of the Command. It's the only required method of the three.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConsoleactionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions