doctrine/orm · error · LogicException
XSD validation cannot be enabled because the DOM extension i
Error message
XSD validation cannot be enabled because the DOM extension is missing.
What it means
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.
Source
Thrown at src/Mapping/Driver/XmlDriver.php:64
public const DEFAULT_FILE_EXTENSION = '.dcm.xml';
/**
* {@inheritDoc}
*/
public function __construct(
string|array|FileLocator $locator,
string $fileExtension = self::DEFAULT_FILE_EXTENSION,
private readonly bool $isXsdValidationEnabled = true,
) {
if (! extension_loaded('simplexml')) {
throw new LogicException(
'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.',
);
}
if ($isXsdValidationEnabled && ! extension_loaded('dom')) {
throw new LogicException(
'XSD validation cannot be enabled because the DOM extension is missing.',
);
}
parent::__construct($locator, $fileExtension);
}
/**
* {@inheritDoc}
*
* @param class-string<T> $className
* @param ClassMetadata<T> $metadata
*
* @template T of object
*/
public function loadMetadataForClass($className, PersistenceClassMetadata $metadata): void
{
$xmlRoot = $this->getElement($className);View on GitHub (pinned to d9b9ff7301)
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.
Example fix
// before $driver = new XmlDriver($configPaths); // LogicException: DOM extension missing // after (option 1: disable validation) $driver = new XmlDriver($configPaths, XmlDriver::DEFAULT_FILE_EXTENSION, false); // after (option 2: fix the runtime) // docker-php-ext-install dom && restart PHP
Defensive patterns
Strategy: validation
Validate before calling
$xsd = extension_loaded('dom'); // expensive envs may skip validation
$driver = new XmlDriver($locator, XmlDriver::DEFAULT_FILE_EXTENSION, $xsd); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The XML metadata driver cannot be enabled because the Simple
- Uninitialized result set mapping.
- Unable to use access strategy type of [%s] without a Concurr
- Unrecognized access strategy type [%s]
- If you want to use a "READ_WRITE" cache an implementation of
AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21).
Data as JSON: /api/errors/0a2099f1a8e1d704.
Report an issue: GitHub.