Symfony Yaml
PHP component for parsing and dumping YAML files, used throughout the Symfony framework
Repository Health
Technical Analysis
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::parseFileto load YAML strings or files into PHP arrays, objects, or constantsYaml::dumpto 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-lintCLI binary andLintCommandfor 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-lintcommand 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 11 apps in this directory
BillaBear
Ecommerce · Invoicing Finance
Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.
Coolify
Devops · Hosting Control Panel
Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in
Craft CMS
CMS
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.
Hyvor Relay
Devops · AI Development · Monitoring
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.
Kimai
Invoicing Finance · Project Management
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.
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira
LinkStack
Marketing
Self-hosted, privacy-focused Linktree alternative with themes, analytics, and a drag-and-drop admin panel.
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.
QuestDB
Databases · Analytics
A high-performance, open-source time-series database built for financial market data, IoT telemetry, and real-time analytics, combining a zero-GC Java/C++ core with SIMD-accelerated SQL and a WAL-to-Parquet storage engine.