Symfony Yaml

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

Library
Composer
vv8.1.9
3,838 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

760

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

View details
73
Repo Health
66
Technical
65
Dependency
Built with
PHP 63%
Vue 18%
Gherkin 13%
Updated 1 months ago
PHP
82%
Apache 2.0

Coolify

Devops · Hosting Control Panel

63,619

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
68
Dependency
Built with
PHP 82%
Blade 13%
Updated yesterday
PHP
78%
Other

Craft CMS

CMS

3,620

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 today
PHP
60%
AGPL 3.0

Hyvor Relay

AI Development · Devops · Monitoring

918

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
69
Repo Health
79
Technical
71
Dependency
Built with
PHP 60%
Svelte 22%
Go 16%
Updated 3 days ago
PHP
87%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

5,095

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 87%
Updated today
PHP
55%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,890

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

View details
90
Repo Health
68
Technical
62
Dependency
Built with
PHP 55%
CSS 18%
Blade 14%
Updated 3 days ago
PHP
65%
AGPL 3.0

LinkStack

Marketing

3,914

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

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

Magic

AI Agents · Automation · Low Code Platforms

5,055

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
68
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 44%
PHP 32%
Updated 2 months ago
PHP
78%
GPL 3.0

matomo

Analytics

21,976

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 yesterday

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