# symfony/console architecture

> Architecture diagram of the GitHub repository symfony/console, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/symfony/console
- Repository: https://github.com/symfony/console

## Overview

Symfony Console is a PHP component for building command-line applications. A user supplies command-line input; the application selects and runs a command, which consumes parsed arguments and options and writes formatted output. The component also provides interactive questions and styles, shell completion, command descriptions, service-container integration, event and signal handling, and Messenger-based command execution. Edges are limited to relationships shown in excerpts, SOURCE INDEX references, or the README; unsampled subsystem wiring is not inferred.

Main entry points: [`Command/Command.php`](https://github.com/symfony/console/blob/8.2/Command/Command.php) (Command), [`Application.php`](https://github.com/symfony/console/blob/8.2/Application.php) (Application), [`Input/InputDefinition.php`](https://github.com/symfony/console/blob/8.2/Input/InputDefinition.php) (Input definition), [`Output/Output.php`](https://github.com/symfony/console/blob/8.2/Output/Output.php) (Output)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_execution["Command execution"]
  node_application["Application<br/>[Application.php]"]
  node_command["Command<br/>[Command.php]"]
  node_argresolver["Argument resolver"]
end

subgraph group_io["Input and output"]
  node_argv["CLI input<br/>[ArgvInput.php]"]
  node_input["Input state<br/>[Input.php]"]
  node_definition["Input definition"]
  node_argument["Argument spec<br/>[InputArgument.php]"]
  node_option["Option spec<br/>[InputOption.php]"]
  node_output["Output<br/>[Output.php]"]
  node_formatter["Output formatter"]
end

subgraph group_interaction["Interactive features"]
  node_question["Questions<br/>[Question.php]"]
  node_style["Console styles<br/>[SymfonyStyle.php]"]
  node_completion["Completion input"]
  node_suggestions["Completion suggestions"]
  node_completioncmd["Completion commands"]
end

subgraph group_integration["Framework integration"]
  node_loader["Command loader"]
  node_di["Command registration"]
  node_events["Console events"]
  node_messenger["Messenger handler"]
end

subgraph group_support["Inspection and help"]
  node_descriptor["Text descriptor<br/>[TextDescriptor.php]"]
  node_help["Help command<br/>[HelpCommand.php]"]
end

node_user(("CLI user"))

node_user -->|"provides tokens"| node_argv
node_application -.->|"parses input"| node_argv
node_application -->|"runs command"| node_command
node_application -->|"loads commands"| node_loader
node_application -->|"routes completion"| node_completioncmd
node_application -->|"dispatches events"| node_events
node_command -->|"configures inputs"| node_definition
node_command -->|"receives input"| node_input
node_command -->|"writes output"| node_output
node_input -->|"binds against"| node_definition
node_definition -->|"stores arguments"| node_argument
node_definition -->|"stores options"| node_option
node_output -->|"formats messages"| node_formatter
node_formatter -.->|"formats writes"| node_output
node_argresolver -->|"resolves parameters"| node_command
node_argresolver -->|"reads values"| node_input
node_completioncmd -.->|"parses completion"| node_completion
node_completion -->|"reads specifications"| node_definition
node_completion -->|"checks options"| node_option
node_command -->|"offers suggestions"| node_suggestions
node_di -->|"registers commands"| node_loader
node_messenger -->|"runs application"| node_application
node_messenger -->|"selects command"| node_command
node_descriptor -->|"describes commands"| node_command
node_descriptor -->|"writes description"| node_output
node_application -.->|"selects help"| node_help
node_style -->|"supports prompts"| node_question

click node_application "https://github.com/symfony/console/blob/8.2/Application.php"
click node_command "https://github.com/symfony/console/blob/8.2/Command/Command.php"
click node_argresolver "https://github.com/symfony/console/blob/8.2/ArgumentResolver/ArgumentResolver.php"
click node_argv "https://github.com/symfony/console/blob/8.2/Input/ArgvInput.php"
click node_input "https://github.com/symfony/console/blob/8.2/Input/Input.php"
click node_definition "https://github.com/symfony/console/blob/8.2/Input/InputDefinition.php"
click node_argument "https://github.com/symfony/console/blob/8.2/Input/InputArgument.php"
click node_option "https://github.com/symfony/console/blob/8.2/Input/InputOption.php"
click node_output "https://github.com/symfony/console/blob/8.2/Output/Output.php"
click node_formatter "https://github.com/symfony/console/blob/8.2/Formatter/OutputFormatter.php"
click node_question "https://github.com/symfony/console/blob/8.2/Question/Question.php"
click node_style "https://github.com/symfony/console/blob/8.2/Style/SymfonyStyle.php"
click node_completion "https://github.com/symfony/console/blob/8.2/Completion/CompletionInput.php"
click node_suggestions "https://github.com/symfony/console/blob/8.2/Completion/CompletionSuggestions.php"
click node_completioncmd "https://github.com/symfony/console/blob/8.2/Command/CompleteCommand.php"
click node_loader "https://github.com/symfony/console/blob/8.2/CommandLoader/ContainerCommandLoader.php"
click node_di "https://github.com/symfony/console/blob/8.2/DependencyInjection/AddConsoleCommandPass.php"
click node_events "https://github.com/symfony/console/blob/8.2/Event/ConsoleCommandEvent.php"
click node_messenger "https://github.com/symfony/console/blob/8.2/Messenger/RunCommandMessageHandler.php"
click node_descriptor "https://github.com/symfony/console/blob/8.2/Descriptor/TextDescriptor.php"
click node_help "https://github.com/symfony/console/blob/8.2/Command/HelpCommand.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_command,node_argresolver,node_user toneBlue
class node_argv,node_input,node_definition,node_argument,node_option,node_output,node_formatter toneAmber
class node_question,node_style,node_completion,node_suggestions,node_completioncmd toneMint
class node_loader,node_di,node_events,node_messenger toneRose
class node_descriptor,node_help toneIndigo
```

## Components

### Command execution

- [Application](https://github.com/symfony/console/blob/8.2/Application.php): `Application.php`
- [Command](https://github.com/symfony/console/blob/8.2/Command/Command.php): `Command/Command.php`
- [Argument resolver](https://github.com/symfony/console/blob/8.2/ArgumentResolver/ArgumentResolver.php): `ArgumentResolver/ArgumentResolver.php`

### Input and output

- [CLI input](https://github.com/symfony/console/blob/8.2/Input/ArgvInput.php): `Input/ArgvInput.php`
- [Input state](https://github.com/symfony/console/blob/8.2/Input/Input.php): `Input/Input.php`
- [Input definition](https://github.com/symfony/console/blob/8.2/Input/InputDefinition.php): `Input/InputDefinition.php`
- [Argument spec](https://github.com/symfony/console/blob/8.2/Input/InputArgument.php): `Input/InputArgument.php`
- [Option spec](https://github.com/symfony/console/blob/8.2/Input/InputOption.php): `Input/InputOption.php`
- [Output](https://github.com/symfony/console/blob/8.2/Output/Output.php): `Output/Output.php`
- [Output formatter](https://github.com/symfony/console/blob/8.2/Formatter/OutputFormatter.php): `Formatter/OutputFormatter.php`

### Interactive features

- [Questions](https://github.com/symfony/console/blob/8.2/Question/Question.php): `Question/Question.php`
- [Console styles](https://github.com/symfony/console/blob/8.2/Style/SymfonyStyle.php): `Style/SymfonyStyle.php`
- [Completion input](https://github.com/symfony/console/blob/8.2/Completion/CompletionInput.php): `Completion/CompletionInput.php`
- [Completion suggestions](https://github.com/symfony/console/blob/8.2/Completion/CompletionSuggestions.php): `Completion/CompletionSuggestions.php`
- [Completion commands](https://github.com/symfony/console/blob/8.2/Command/CompleteCommand.php): `Command/CompleteCommand.php`

### Framework integration

- [Command loader](https://github.com/symfony/console/blob/8.2/CommandLoader/ContainerCommandLoader.php): `CommandLoader/ContainerCommandLoader.php`
- [Command registration](https://github.com/symfony/console/blob/8.2/DependencyInjection/AddConsoleCommandPass.php): `DependencyInjection/AddConsoleCommandPass.php`
- [Console events](https://github.com/symfony/console/blob/8.2/Event/ConsoleCommandEvent.php): `Event/ConsoleCommandEvent.php`
- [Messenger handler](https://github.com/symfony/console/blob/8.2/Messenger/RunCommandMessageHandler.php): `Messenger/RunCommandMessageHandler.php`

### Inspection and help

- [Text descriptor](https://github.com/symfony/console/blob/8.2/Descriptor/TextDescriptor.php): `Descriptor/TextDescriptor.php`
- [Help command](https://github.com/symfony/console/blob/8.2/Command/HelpCommand.php): `Command/HelpCommand.php`

### Other components

- **CLI user**

## Connections

- CLI user → CLI input: provides tokens
- Application → CLI input: parses input (evidence: `Application.php`)
- Application → Command: runs command (evidence: `Application.php`)
- Application → Command loader: loads commands (evidence: `Application.php`)
- Application → Completion commands: routes completion (evidence: `Application.php`)
- Application → Console events: dispatches events (evidence: `Application.php`)
- Command → Input definition: configures inputs (evidence: `Command/Command.php`)
- Command → Input state: receives input (evidence: `Command/Command.php`)
- Command → Output: writes output (evidence: `Command/Command.php`)
- Input state → Input definition: binds against (evidence: `Input/Input.php`)
- Input definition → Argument spec: stores arguments (evidence: `Input/InputDefinition.php`)
- Input definition → Option spec: stores options (evidence: `Input/InputDefinition.php`)
- Output → Output formatter: formats messages (evidence: `Output/Output.php`)
- Output formatter → Output: formats writes (evidence: `Output/Output.php`)
- Argument resolver → Command: resolves parameters (evidence: `ArgumentResolver/ArgumentResolver.php`)
- Argument resolver → Input state: reads values (evidence: `ArgumentResolver/ArgumentResolver.php`)
- Completion commands → Completion input: parses completion
- Completion input → Input definition: reads specifications (evidence: `Completion/CompletionInput.php`)
- Completion input → Option spec: checks options (evidence: `Completion/CompletionInput.php`)
- Command → Completion suggestions: offers suggestions (evidence: `Command/Command.php`)
- Command registration → Command loader: registers commands (evidence: `DependencyInjection/AddConsoleCommandPass.php`)
- Messenger handler → Application: runs application (evidence: `Messenger/RunCommandMessageHandler.php`)
- Messenger handler → Command: selects command (evidence: `Messenger/RunCommandMessageHandler.php`)
- Text descriptor → Command: describes commands (evidence: `Descriptor/TextDescriptor.php`)
- Text descriptor → Output: writes description (evidence: `Descriptor/TextDescriptor.php`)
- Application → Help command: selects help (evidence: `Application.php`)
- Console styles → Questions: supports prompts (evidence: `Style/SymfonyStyle.php`)
