# symfony/yaml architecture

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

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

## Overview

Symfony’s Yaml component is a PHP library for loading YAML into PHP values and dumping PHP values as YAML. Its main workflow is parse input through the public Yaml API, with Parser handling block structure and Inline handling inline values; the reverse path uses Dumper. The lint command adds file discovery, parsing, and optional JSON Schema validation. The graph includes parser state, escaping, tagged values, schema support, and exceptions. Some internal calls are inferred only from the SOURCE INDEX references; unsampled details are not expanded.

Main entry points: [`Parser.php`](https://github.com/symfony/yaml/blob/8.2/Parser.php) (Block parser), [`Inline.php`](https://github.com/symfony/yaml/blob/8.2/Inline.php) (Inline parser), [`Schema/SchemaValidator.php`](https://github.com/symfony/yaml/blob/8.2/Schema/SchemaValidator.php) (Schema validator), [`Command/LintCommand.php`](https://github.com/symfony/yaml/blob/8.2/Command/LintCommand.php) (YAML lint command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api_parse["Parsing"]
  node_yaml_api["Yaml API<br/>[Yaml.php]"]
  node_parser["Block parser<br/>[Parser.php]"]
  node_inline["Inline parser<br/>[Inline.php]"]
  node_parser_state["Parser state<br/>[ParserState.php]"]
  node_unescaper["Unescaper<br/>[Unescaper.php]"]
end

subgraph group_api_dump["Dumping"]
  node_dumper["Dumper<br/>[Dumper.php]"]
  node_escaper["Escaper<br/>[Escaper.php]"]
end

subgraph group_schema_lint["Validation and linting"]
  node_lint["YAML lint command<br/>[LintCommand.php]"]
  node_schema_resolver["File schema resolver"]
  node_resolver_contract["Resolver contract"]
  node_schema_validator["Schema validator"]
  node_validator_contract["Validator contract"]
end

subgraph group_errors_tags["Shared types"]
  node_tagged_value["Tagged value<br/>[TaggedValue.php]"]
  node_parse_exception["Parse exception<br/>[ParseException.php]"]
  node_runtime_exception["Runtime exception"]
  node_logic_exception["Logic exception<br/>[LogicException.php]"]
  node_exception_contract["Exception contract"]
end

node_yaml_api -->|"delegates parsing"| node_parser
node_yaml_api -->|"delegates dumping"| node_dumper
node_parser -->|"parses inline values"| node_inline
node_parser -->|"tracks parse state"| node_parser_state
node_parser -->|"creates tagged values"| node_tagged_value
node_parser -->|"throws parse errors"| node_parse_exception
node_inline -->|"tracks parse state"| node_parser_state
node_inline -->|"creates tagged values"| node_tagged_value
node_inline -->|"throws parse errors"| node_parse_exception
node_inline -->|"uses unescaping"| node_unescaper
node_dumper -->|"formats inline values"| node_inline
node_dumper -->|"handles tagged values"| node_tagged_value
node_lint -->|"parses YAML files"| node_parser
node_lint -->|"resolves schemas"| node_schema_resolver
node_lint -->|"validates parsed data"| node_schema_validator
node_schema_resolver -->|"implements"| node_resolver_contract
node_schema_validator -->|"implements"| node_validator_contract
node_schema_validator -->|"raises validation errors"| node_runtime_exception
node_schema_validator -->|"raises support errors"| node_logic_exception
node_parse_exception -->|"extends"| node_runtime_exception
node_runtime_exception -->|"implements"| node_exception_contract
node_logic_exception -->|"implements"| node_exception_contract

click node_yaml_api "https://github.com/symfony/yaml/blob/8.2/Yaml.php"
click node_parser "https://github.com/symfony/yaml/blob/8.2/Parser.php"
click node_inline "https://github.com/symfony/yaml/blob/8.2/Inline.php"
click node_parser_state "https://github.com/symfony/yaml/blob/8.2/ParserState.php"
click node_unescaper "https://github.com/symfony/yaml/blob/8.2/Unescaper.php"
click node_dumper "https://github.com/symfony/yaml/blob/8.2/Dumper.php"
click node_escaper "https://github.com/symfony/yaml/blob/8.2/Escaper.php"
click node_lint "https://github.com/symfony/yaml/blob/8.2/Command/LintCommand.php"
click node_schema_resolver "https://github.com/symfony/yaml/blob/8.2/Schema/FileHeaderSchemaResolver.php"
click node_resolver_contract "https://github.com/symfony/yaml/blob/8.2/Schema/SchemaResolverInterface.php"
click node_schema_validator "https://github.com/symfony/yaml/blob/8.2/Schema/SchemaValidator.php"
click node_validator_contract "https://github.com/symfony/yaml/blob/8.2/Schema/SchemaValidatorInterface.php"
click node_tagged_value "https://github.com/symfony/yaml/blob/8.2/Tag/TaggedValue.php"
click node_parse_exception "https://github.com/symfony/yaml/blob/8.2/Exception/ParseException.php"
click node_runtime_exception "https://github.com/symfony/yaml/blob/8.2/Exception/RuntimeException.php"
click node_logic_exception "https://github.com/symfony/yaml/blob/8.2/Exception/LogicException.php"
click node_exception_contract "https://github.com/symfony/yaml/blob/8.2/Exception/ExceptionInterface.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_yaml_api,node_parser,node_inline,node_parser_state,node_unescaper toneBlue
class node_dumper,node_escaper toneAmber
class node_lint,node_schema_resolver,node_resolver_contract,node_schema_validator,node_validator_contract toneMint
class node_tagged_value,node_parse_exception,node_runtime_exception,node_logic_exception,node_exception_contract toneRose
```

## Components

### Parsing

- [Yaml API](https://github.com/symfony/yaml/blob/8.2/Yaml.php): `Yaml.php`
- [Block parser](https://github.com/symfony/yaml/blob/8.2/Parser.php): `Parser.php`
- [Inline parser](https://github.com/symfony/yaml/blob/8.2/Inline.php): `Inline.php`
- [Parser state](https://github.com/symfony/yaml/blob/8.2/ParserState.php): `ParserState.php`
- [Unescaper](https://github.com/symfony/yaml/blob/8.2/Unescaper.php): `Unescaper.php`

### Dumping

- [Dumper](https://github.com/symfony/yaml/blob/8.2/Dumper.php): `Dumper.php`
- [Escaper](https://github.com/symfony/yaml/blob/8.2/Escaper.php): `Escaper.php`

### Validation and linting

- [YAML lint command](https://github.com/symfony/yaml/blob/8.2/Command/LintCommand.php): `Command/LintCommand.php`
- [File schema resolver](https://github.com/symfony/yaml/blob/8.2/Schema/FileHeaderSchemaResolver.php): `Schema/FileHeaderSchemaResolver.php`
- [Resolver contract](https://github.com/symfony/yaml/blob/8.2/Schema/SchemaResolverInterface.php): `Schema/SchemaResolverInterface.php`
- [Schema validator](https://github.com/symfony/yaml/blob/8.2/Schema/SchemaValidator.php): `Schema/SchemaValidator.php`
- [Validator contract](https://github.com/symfony/yaml/blob/8.2/Schema/SchemaValidatorInterface.php): `Schema/SchemaValidatorInterface.php`

### Shared types

- [Tagged value](https://github.com/symfony/yaml/blob/8.2/Tag/TaggedValue.php): `Tag/TaggedValue.php`
- [Parse exception](https://github.com/symfony/yaml/blob/8.2/Exception/ParseException.php): `Exception/ParseException.php`
- [Runtime exception](https://github.com/symfony/yaml/blob/8.2/Exception/RuntimeException.php): `Exception/RuntimeException.php`
- [Logic exception](https://github.com/symfony/yaml/blob/8.2/Exception/LogicException.php): `Exception/LogicException.php`
- [Exception contract](https://github.com/symfony/yaml/blob/8.2/Exception/ExceptionInterface.php): `Exception/ExceptionInterface.php`

## Connections

- Yaml API → Block parser: delegates parsing (evidence: `Yaml.php`)
- Yaml API → Dumper: delegates dumping (evidence: `Yaml.php`)
- Block parser → Inline parser: parses inline values (evidence: `Parser.php`)
- Block parser → Parser state: tracks parse state (evidence: `Parser.php`)
- Block parser → Tagged value: creates tagged values (evidence: `Parser.php`)
- Block parser → Parse exception: throws parse errors (evidence: `Parser.php`)
- Inline parser → Parser state: tracks parse state (evidence: `Inline.php`)
- Inline parser → Tagged value: creates tagged values (evidence: `Inline.php`)
- Inline parser → Parse exception: throws parse errors (evidence: `Inline.php`)
- Inline parser → Unescaper: uses unescaping (evidence: `Inline.php`)
- Dumper → Inline parser: formats inline values (evidence: `Dumper.php`)
- Dumper → Tagged value: handles tagged values (evidence: `Dumper.php`)
- YAML lint command → Block parser: parses YAML files (evidence: `Command/LintCommand.php`)
- YAML lint command → File schema resolver: resolves schemas (evidence: `Command/LintCommand.php`)
- YAML lint command → Schema validator: validates parsed data (evidence: `Command/LintCommand.php`)
- File schema resolver → Resolver contract: implements (evidence: `Schema/FileHeaderSchemaResolver.php`)
- Schema validator → Validator contract: implements (evidence: `Schema/SchemaValidator.php`)
- Schema validator → Runtime exception: raises validation errors (evidence: `Schema/SchemaValidator.php`)
- Schema validator → Logic exception: raises support errors (evidence: `Schema/SchemaValidator.php`)
- Parse exception → Runtime exception: extends (evidence: `Exception/ParseException.php`)
- Runtime exception → Exception contract: implements (evidence: `Exception/RuntimeException.php`)
- Logic exception → Exception contract: implements (evidence: `Exception/LogicException.php`)
