{"record":{"id":"0a2099f1a8e1d704","repo":"doctrine/orm","slug":"xsd-validation-cannot-be-enabled-because-the-dom-e","errorCode":null,"errorMessage":"XSD validation cannot be enabled because the DOM extension is missing.","messagePattern":"XSD validation cannot be enabled because the DOM extension is missing\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Mapping/Driver/XmlDriver.php","lineNumber":64,"sourceCode":"    public const DEFAULT_FILE_EXTENSION = '.dcm.xml';\n\n    /**\n     * {@inheritDoc}\n     */\n    public function __construct(\n        string|array|FileLocator $locator,\n        string $fileExtension = self::DEFAULT_FILE_EXTENSION,\n        private readonly bool $isXsdValidationEnabled = true,\n    ) {\n        if (! extension_loaded('simplexml')) {\n            throw new LogicException(\n                'The XML metadata driver cannot be enabled because the SimpleXML PHP extension is missing.'\n                . ' Please configure PHP with SimpleXML or choose a different metadata driver.',\n            );\n        }\n\n        if ($isXsdValidationEnabled && ! extension_loaded('dom')) {\n            throw new LogicException(\n                'XSD validation cannot be enabled because the DOM extension is missing.',\n            );\n        }\n\n        parent::__construct($locator, $fileExtension);\n    }\n\n    /**\n     * {@inheritDoc}\n     *\n     * @param class-string<T>  $className\n     * @param ClassMetadata<T> $metadata\n     *\n     * @template T of object\n     */\n    public function loadMetadataForClass($className, PersistenceClassMetadata $metadata): void\n    {\n        $xmlRoot = $this->getElement($className);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Mapping/Driver/XmlDriver.php#L46-L82","documentation":"XmlDriver optionally validates every .dcm.xml file against Doctrine's XSD schema ($isXsdValidationEnabled, true by default). XSD validation is done with the DOM extension, so when validation is requested but ext-dom is missing the constructor throws a LogicException instead of silently shipping unvalidated mappings.","triggerScenarios":"new XmlDriver($locator) (default third argument true) or explicitly new XmlDriver($locator, '.dcm.xml', true) on a PHP build where ext-dom is not loaded — usually the same minimal images that also lack simplexml.","commonSituations":"Minimal Docker/alpine PHP images where xml/dom packages are not installed; production servers provisioned without php-xml; enabling XSD validation deliberately in CI to catch malformed mapping files.","solutions":["Install/enable ext-dom: docker-php-ext-install dom, apt install php-xml, or apk add php83-dom, then restart PHP.","If DOM is unavailable and you accept skipping validation, pass false explicitly: new XmlDriver($locator, XmlDriver::DEFAULT_FILE_EXTENSION, false).","Keep validation enabled in CI (where you control the image) and only disable it in constrained runtimes."],"exampleFix":"// before\n$driver = new XmlDriver($configPaths); // LogicException: DOM extension missing\n\n// after (option 1: disable validation)\n$driver = new XmlDriver($configPaths, XmlDriver::DEFAULT_FILE_EXTENSION, false);\n// after (option 2: fix the runtime)\n//   docker-php-ext-install dom  && restart PHP","handlingStrategy":"validation","validationCode":"$xsd = extension_loaded('dom'); // expensive envs may skip validation\n$driver = new XmlDriver($locator, XmlDriver::DEFAULT_FILE_EXTENSION, $xsd);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the full php-xml bundle (simplexml + dom) on all environments.","Keep XSD validation enabled wherever possible — it catches malformed mappings early.","If you must disable validation in prod, keep it on in CI."],"tags":["doctrine-orm","xml-driver","php-extension","xsd-validation","environment"],"backgroundTag":"missing-php-extension","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}