{"record":{"id":"ab637d129863898a","repo":"symfony/translation","slug":"dumping-translations-in-the-yaml-format-requires-the-symfony","errorCode":null,"errorMessage":"Dumping translations in the YAML format requires the Symfony Yaml component.","messagePattern":"Dumping translations in the YAML format requires the Symfony Yaml component\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Dumper/YamlFileDumper.php","lineNumber":34,"sourceCode":"use Symfony\\Component\\Translation\\Util\\ArrayConverter;\nuse Symfony\\Component\\Yaml\\Yaml;\n\n/**\n * YamlFileDumper generates yaml files from a message catalogue.\n *\n * @author Michel Salib <michelsalib@hotmail.com>\n */\nclass YamlFileDumper extends FileDumper\n{\n    public function __construct(\n        private string $extension = 'yml',\n    ) {\n    }\n\n    public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string\n    {\n        if (!class_exists(Yaml::class)) {\n            throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');\n        }\n\n        $data = $messages->all($domain);\n\n        if (isset($options['as_tree']) && $options['as_tree']) {\n            $data = ArrayConverter::expandToTree($data);\n        }\n\n        if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) {\n            return Yaml::dump($data, $inline);\n        }\n\n        return Yaml::dump($data);\n    }\n\n    protected function getExtension(): string\n    {\n        return $this->extension;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Dumper/YamlFileDumper.php#L16-L52","documentation":"Thrown by YamlFileDumper::formatCatalogue when the symfony/yaml component (Yaml class) is not installed. The dumper cannot serialize translations to YAML without it, since symfony/translation does not hard-require symfony/yaml.","triggerScenarios":"Running translation dump commands or programmatic dumping to YAML format in a project where symfony/yaml was never installed or was removed from composer dependencies.","commonSituations":"Slim composer installs (framework without yaml — unusual in full Symfony, common in minimal setups using only symfony/translation); CI images with stripped dependencies; after removing symfony/yaml in a dependency cleanup.","solutions":["Install the Yaml component: `composer require symfony/yaml`","Or dump to a different format (e.g. xliff, php) that does not need YAML","If in a custom build, ensure symfony/yaml is a direct require, not assumed transitively"],"exampleFix":"// before\ncomposer remove symfony/yaml\n// after\ncomposer require symfony/yaml","handlingStrategy":"fallback","validationCode":"if (!class_exists(\\Symfony\\Component\\Yaml\\Yaml::class)) { // choose a non-YAML format or require symfony/yaml }","typeGuard":"function yamlDumperAvailable(): bool { return class_exists(\\Symfony\\Component\\Yaml\\Yaml::class); }","tryCatchPattern":"try { $dumper->dump($catalogue, $options); } catch (LogicException $e) { if (str_contains($e->getMessage(), 'Yaml component')) { $xliffDumper->dump($catalogue, $options); } else { throw $e; } }","preventionTips":["Explicitly `composer require symfony/yaml` whenever you use YAML dumpers","Run `composer check-platform-reqs` / dependency audits in CI to catch dropped packages","In slim projects, list every Symfony component you actually use as a direct dependency"],"tags":["symfony","translation","yaml","missing-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}