{"record":{"id":"0920beea77797ab3","repo":"doctrine/orm","slug":"the-xml-metadata-driver-cannot-be-enabled-because","errorCode":null,"errorMessage":"The XML metadata driver cannot be enabled because the SimpleXML PHP extension is missing. Please configure PHP with SimpleXML or choose a different metadata driver.","messagePattern":"The XML metadata driver cannot be enabled because the SimpleXML PHP extension is missing\\. Please configure PHP with SimpleXML or choose a different metadata driver\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Mapping/Driver/XmlDriver.php","lineNumber":57,"sourceCode":" *\n * @template-extends FileDriver<SimpleXMLElement>\n */\nclass XmlDriver extends FileDriver\n{\n    use LoadMappingFileImplementation;\n\n    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","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Mapping/Driver/XmlDriver.php#L39-L75","documentation":"The XmlDriver parses Doctrine's .dcm.xml mapping files with SimpleXML, so its constructor hard-fails with a LogicException when the simplexml extension is not loaded, before any mapping work starts. The message tells you to either compile the extension into PHP or pick a different metadata driver.","triggerScenarios":"Instantiating new XmlDriver($locator) on a PHP build without ext-simplexml — typically slim Docker images (alpine php:8*-cli without docker-php-ext-install simplexml) or distro PHP installs where the php-xml package was never installed.","commonSituations":"Alpine/slim production or CI images; php:fpm images where only selected extensions were enabled; hardened hosting where simplexml is disabled; switching a project to XML mappings on a server provisioned for attribute mappings.","solutions":["Install/enable the extension: docker-php-ext-install simplexml (Docker), apt install php-xml (Debian/Ubuntu), apk add php83-simplexml (Alpine), then restart PHP-FPM/CLI.","Verify with php -m | grep -i simplexml before deploying.","If you cannot change the runtime, switch the project to the AttributeDriver (attributes) so no XML parsing is needed."],"exampleFix":"# before (Dockerfile)\nFROM php:8.3-cli\n# XmlDriver throws: SimpleXML missing\n\n# after\nFROM php:8.3-cli\nRUN docker-php-ext-install simplexml dom","handlingStrategy":"validation","validationCode":"if (! extension_loaded('simplexml')) {\n    throw new RuntimeException('XML mappings require ext-simplexml; install it or use the AttributeDriver.');\n}\n$driver = new XmlDriver($locator);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bake required extensions into Dockerfiles (docker-php-ext-install simplexml dom).","Add a bootstrap check listing required extensions for the chosen metadata driver.","Match CI/production images so extension drift is caught before deploy."],"tags":["doctrine-orm","xml-driver","php-extension","environment","docker"],"backgroundTag":"missing-php-extension","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}