Symfony Yaml

PHP component for parsing and dumping YAML files, used throughout the Symfony framework

Library
Composer
vv8.1.6
3,837 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
88 /100 Excellent
Development Activity 96
Maintenance 96
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 83
Code Quality 86
Innovation 70
Learning Curve 82

Symfony Yaml is a PHP library that converts YAML documents into native PHP arrays and objects (Yaml::parse, Yaml::parseFile) and serializes PHP data structures back into YAML (Yaml::dump). It implements the YAML 1.2 specification closely enough to pass the official yaml-test-suite, while offering Symfony-specific extensions like parsing PHP constants, objects, and custom tags via bitmask flags.

As one of Symfony’s foundational components, it underpins configuration loading across the framework (service definitions, routing, and application config) but is fully decoupled and usable standalone in any PHP 8.4+ project. It ships a yaml-lint CLI binary and a LintCommand for integrating YAML validation into Symfony Console applications, plus detailed parse exceptions that report the exact line and context of a syntax error.

What You Get

  • Yaml::parse/Yaml::parseFile to load YAML strings or files into PHP arrays, objects, or constants
  • Yaml::dump to serialize PHP arrays and objects back into YAML text with configurable inline depth and indentation
  • A bitmask of PARSE_*/DUMP_* flags for behaviors like parsing PHP constants, custom tags, or dumping objects as YAML maps
  • A yaml-lint CLI binary and LintCommand for validating YAML files from the command line or a Symfony Console app
  • Detailed ParseExceptions that report the exact line number and surrounding context of invalid YAML

Common Use Cases

  • Loading application configuration files (services, routing, environment-specific settings) in a Symfony or standalone PHP project
  • Validating YAML files in CI via the bundled yaml-lint command before deployment
  • Converting PHP data structures to human-readable YAML for config export, fixtures, or API documentation snippets
  • Parsing third-party YAML files (CI pipelines, OpenAPI specs, Docker Compose files) inside a PHP tool

Under The Hood

Architecture - The component separates parsing from dumping across two focused classes: Parser.php (1,332 lines) implements a recursive-descent parser that walks YAML line-by-line, tracking indentation and nesting to build a PHP value tree, while Inline.php (983 lines) handles single-line/flow-style YAML fragments ({key: value}, [a, b]) shared by both parsing and dumping. Dumper.php (199 lines) walks a PHP value and serializes it back to YAML text using the same Inline helpers for scalar formatting. The public entry point, Yaml.php, is a thin static facade (parse/parseFile/dump) over Parser and Dumper, keeping the internal classes swappable without breaking the documented API. Tech Stack - Requires PHP 8.4.1+, with symfony/polyfill-ctype as the only hard runtime dependency; symfony/console is an optional dev/conflict dependency used solely to power the LintCommand integration. The Yaml\ namespace is autoloaded via PSR-4, and the package declares a bin/yaml-lint executable installed alongside the library. Code Quality - The Tests/ directory includes dedicated suites for the parser, dumper, inline handling, exceptions, and a YamlTestSuiteTest that runs the component against the official cross-language yaml-test-suite fixtures, giving strong confidence in spec conformance across edge cases (anchors, merge keys, multi-document streams). Error handling is deliberate: ParseException captures the parsed line number and snippet rather than failing with a generic message. API Design - The static Yaml::parse/Yaml::dump facade requires no instantiation for the common case, while power users can flag in specific behaviors (object parsing, constant resolution, custom tags) via well-documented bitmask constants rather than a sprawling options array. Every public method carries a full PHPDoc block with parameter semantics, keeping IDE autocompletion and static analysis useful even without reading the source.

Used by 12 apps in this directory

PHP
63%
Other

BillaBear

Ecommerce · Invoicing Finance

761

Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.

View details
76
Repo Health
66
Technical
65
Dependency
Built with
PHP 63%
Vue 18%
Gherkin 13%
Updated 2 weeks ago
PHP
81%
Apache 2.0

Coolify

Devops · Hosting Control Panel

62,328

Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in

View details
92
Repo Health
86
Technical
70
Dependency
Built with
PHP 81%
Blade 16%
Updated 5 days ago
PHP
78%
Other

Craft CMS

CMS

3,609

A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.

View details
96
Repo Health
83
Technical
62
Dependency
Built with
PHP 78%
JavaScript 14%
Updated 5 days ago
PHP
63%
AGPL 3.0

Hyvor Relay

AI Development · Devops · Monitoring

908

Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.

View details
68
Repo Health
79
Technical
70
Dependency
Built with
PHP 63%
Svelte 23%
Go 11%
Updated 1 weeks ago
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

5,046

Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.

View details
94
Repo Health
78
Technical
64
Dependency
Built with
PHP 86%
Updated 4 days ago
PHP
48%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,672

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
65
Dependency
Built with
PHP 48%
CSS 20%
Blade 17%
Updated 1 weeks ago
PHP
65%
AGPL 3.0

LinkStack

Marketing

3,888

Self-hosted, privacy-focused Linktree alternative with themes, analytics, and a drag-and-drop admin panel.

View details
66
Repo Health
56
Technical
68
Dependency
Built with
PHP 65%
Blade 35%
Updated 2 months ago
TypeScript
44%
Other

Magic

AI Agents · Automation · Low Code Platforms

5,043

Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.

View details
70
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 44%
PHP 32%
Updated 1 months ago
PHP
78%
GPL 3.0

matomo

Analytics

21,905

Open-source, privacy-first web and app analytics that puts you in complete control of your data.

View details
95
Repo Health
82
Technical
62
Dependency
Built with
PHP 78%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers