doctrine/orm · error · LogicException
Lazy loading proxies require PHP 8.4 or higher.
Error message
Lazy loading proxies require PHP 8.4 or higher.
What it means
LogicException from Configuration::enableNativeLazyObjects() (src/Configuration.php:669). Native lazy objects (PHP 8.4 ReflectionClass::newLazyGhost-based proxies) are implemented with runtime APIs that only exist in PHP 8.4; enabling the feature on an older runtime is rejected rather than crashing later during proxy generation.
Source
Thrown at src/Configuration.php:669
}
public function isNativeLazyObjectsEnabled(): bool
{
return $this->attributes['nativeLazyObjects'] ?? false;
}
public function enableNativeLazyObjects(bool $nativeLazyObjects): void
{
if (PHP_VERSION_ID >= 80400 && ! $nativeLazyObjects) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/12005',
'Disabling native lazy objects is deprecated and will be impossible in Doctrine ORM 4.0.',
);
}
if (PHP_VERSION_ID < 80400 && $nativeLazyObjects) {
throw new LogicException('Lazy loading proxies require PHP 8.4 or higher.');
}
$this->attributes['nativeLazyObjects'] = $nativeLazyObjects;
}
/**
* @deprecated lazy ghost objects are always enabled
*
* @return true
*/
public function isLazyGhostObjectEnabled(): bool
{
return true;
}
/** @deprecated lazy ghost objects cannot be disabled */
public function setLazyGhostObjectEnabled(bool $flag): void
{View on GitHub (pinned to d9b9ff7301)
Solutions
- Run the application on PHP >= 8.4 (check php -v for both CLI and php-fpm; also CI images and deploy containers).
- Until upgraded, gate the call: if (PHP_VERSION_ID >= 80400) { $config->enableNativeLazyObjects(true); } — the classic proxy mechanism remains the default below 8.4.
- If the flag comes from framework config, make it env-dependent (e.g. native_lazy_objects: '%env(bool:ORM_NATIVE_LAZY)%') and default it off on old runtimes.
Example fix
// before
$config = new Configuration();
$config->enableNativeLazyObjects(true); // LogicException on PHP 8.3
// after
$config = new Configuration();
if (PHP_VERSION_ID >= 80400) {
$config->enableNativeLazyObjects(true);
} Defensive patterns
Strategy: validation
Validate before calling
if (PHP_VERSION_ID >= 80400) {
$config->enableNativeLazyObjects(true);
} // else: keep default proxy-based lazy loading Prevention
- Pin the deployed PHP version in CI matrices equal to production when testing native-lazy-object features.
- Derive the config flag from an env var so dev/staging on older PHP stay safe.
- Add composer platform config (php: >=8.4) if the whole project depends on the feature.
When it happens
Trigger: Calling $configuration->enableNativeLazyObjects(true) — directly or via framework config (e.g. Symfony's doctrine bundle native_lazy_objects / ORMSetup helper) — on a process running PHP < 8.4.0 (PHP_VERSION_ID < 80400).
Common situations: Config written against PHP 8.4 deployed to CI/staging on 8.2/8.3; local dev on an older PHP while production is 8.4; Composer platform check not enforcing the version because the setting is runtime config, not a dependency.
Related errors
- If you want to use a "READ_WRITE" cache an implementation of
- The lazy ghost object feature cannot be disabled anymore. Pl
- Rejecting ID collisions in the identity map cannot be disabl
- Unknown property {key} on class {class}
- Invalid cache usage "%s"
AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21).
Data as JSON: /api/errors/e33cc4a59e78d123.
Report an issue: GitHub.