symfony/translation · error · RuntimeException

Loading translations from the Xliff format requires the…

Error message

Loading translations from the Xliff format requires the Symfony Config component.

What it means

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.

Solutions

  1. Run composer require symfony/config to install the missing component.
  2. If you do not need XLIFF, use a loader whose dependencies you have (e.g. YAML/PHP loaders) instead.
  3. Verify vendor/ contains Symfony/Component/Config/Util/XmlUtils.php after install.

Example fix

// before
$loader = new XliffFileLoader(); // RuntimeException: requires Symfony Config
// after
// composer require symfony/config
$loader = new XliffFileLoader();
Defensive patterns

Strategy: try-catch

Validate before calling

if (!class_exists(\Symfony\Component\Config\Util\XmlUtils::class)) {
    throw new \LogicException('Install symfony/config before loading XLIFF translations.');
}

Type guard

function canLoadXliff(): bool { return class_exists(\Symfony\Component\Config\Util\XmlUtils::class); }

Try / catch

try {
    $catalogue = $loader->load($resource, $locale);
} catch (\RuntimeException $e) {
    if (str_contains($e->getMessage(), 'requires the Symfony Config component')) {
        // install symfony/config or fall back to another loader
    }
    throw $e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15). Data as JSON: /api/errors/2b08fcbb1585e3ae. Report an issue: GitHub.

Appendix: source

Thrown at Loader/XliffFileLoader.php:35

use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\Exception\RuntimeException;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\MessageCatalogueInterface;
use Symfony\Component\Translation\Util\XliffUtils;

/**
 * XliffFileLoader loads translations from XLIFF files.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class XliffFileLoader implements LoaderInterface
{
    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
    {
        if (!class_exists(XmlUtils::class)) {
            throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.');
        }

        if (!$this->isXmlString($resource)) {
            if (!stream_is_local($resource)) {
                throw new InvalidResourceException(\sprintf('This is not a local file "%s".', $resource));
            }

            if (!file_exists($resource)) {
                throw new NotFoundResourceException(\sprintf('File "%s" not found.', $resource));
            }

            if (!is_file($resource)) {
                throw new InvalidResourceException(\sprintf('This is neither a file nor an XLIFF string "%s".', $resource));
            }
        }

        try {
            if ($this->isXmlString($resource)) {

View on GitHub (pinned to ae9e8a51bc)