{"record":{"id":"2b08fcbb1585e3ae","repo":"symfony/translation","slug":"loading-translations-from-the-xliff-format-requires-the","errorCode":null,"errorMessage":"Loading translations from the Xliff format requires the Symfony Config component.","messagePattern":"Loading translations from the Xliff format requires the Symfony Config component\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Loader/XliffFileLoader.php","lineNumber":35,"sourceCode":"use Symfony\\Component\\Config\\Util\\XmlUtils;\nuse Symfony\\Component\\Translation\\Exception\\InvalidResourceException;\nuse Symfony\\Component\\Translation\\Exception\\NotFoundResourceException;\nuse Symfony\\Component\\Translation\\Exception\\RuntimeException;\nuse Symfony\\Component\\Translation\\MessageCatalogue;\nuse Symfony\\Component\\Translation\\MessageCatalogueInterface;\nuse Symfony\\Component\\Translation\\Util\\XliffUtils;\n\n/**\n * XliffFileLoader loads translations from XLIFF files.\n *\n * @author Fabien Potencier <fabien@symfony.com>\n */\nclass XliffFileLoader implements LoaderInterface\n{\n    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue\n    {\n        if (!class_exists(XmlUtils::class)) {\n            throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.');\n        }\n\n        if (!$this->isXmlString($resource)) {\n            if (!stream_is_local($resource)) {\n                throw new InvalidResourceException(\\sprintf('This is not a local file \"%s\".', $resource));\n            }\n\n            if (!file_exists($resource)) {\n                throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n            }\n\n            if (!is_file($resource)) {\n                throw new InvalidResourceException(\\sprintf('This is neither a file nor an XLIFF string \"%s\".', $resource));\n            }\n        }\n\n        try {\n            if ($this->isXmlString($resource)) {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/XliffFileLoader.php#L17-L53","documentation":"XliffFileLoader parses XLIFF translation files using Symfony's XmlUtils, which lives in the symfony/config component. If that component is not installed, the loader cannot do its work and throws this RuntimeException immediately. It is a guard for an optional dependency of the translation component.","triggerScenarios":"Calling XliffFileLoader::load() (directly or via a Translator/translation push pipeline, as in the testPush* callers) while symfony/config is absent, so class_exists(XmlUtils::class) fails.","commonSituations":"Projects that installed only symfony/translation without symfony/config, or removed the dependency during a dependency cleanup; Composer package replaced/downgraded so Config component got dropped.","solutions":["Run composer require symfony/config to install the missing component.","If you do not need XLIFF, use a loader whose dependencies you have (e.g. YAML/PHP loaders) instead.","Verify vendor/ contains Symfony/Component/Config/Util/XmlUtils.php after install."],"exampleFix":"// before\n$loader = new XliffFileLoader(); // RuntimeException: requires Symfony Config\n// after\n// composer require symfony/config\n$loader = new XliffFileLoader();","handlingStrategy":"try-catch","validationCode":"if (!class_exists(\\Symfony\\Component\\Config\\Util\\XmlUtils::class)) {\n    throw new \\LogicException('Install symfony/config before loading XLIFF translations.');\n}","typeGuard":"function canLoadXliff(): bool { return class_exists(\\Symfony\\Component\\Config\\Util\\XmlUtils::class); }","tryCatchPattern":"try {\n    $catalogue = $loader->load($resource, $locale);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'requires the Symfony Config component')) {\n        // install symfony/config or fall back to another loader\n    }\n    throw $e;\n}","preventionTips":["Require symfony/config explicitly in composer.json when using XLIFF translations.","Add a CI check that runs translation loading in a clean vendor install.","Prefer a loader matching your installed components."],"tags":["php","missing-dependency","xliff"],"backgroundTag":"missing-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"}