{"record":{"id":"e33cc4a59e78d123","repo":"doctrine/orm","slug":"lazy-loading-proxies-require-php-8-4-or-higher","errorCode":null,"errorMessage":"Lazy loading proxies require PHP 8.4 or higher.","messagePattern":"Lazy loading proxies require PHP 8\\.4 or higher\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Configuration.php","lineNumber":669,"sourceCode":"    }\n\n    public function isNativeLazyObjectsEnabled(): bool\n    {\n        return $this->attributes['nativeLazyObjects'] ?? false;\n    }\n\n    public function enableNativeLazyObjects(bool $nativeLazyObjects): void\n    {\n        if (PHP_VERSION_ID >= 80400 && ! $nativeLazyObjects) {\n            Deprecation::trigger(\n                'doctrine/orm',\n                'https://github.com/doctrine/orm/pull/12005',\n                'Disabling native lazy objects is deprecated and will be impossible in Doctrine ORM 4.0.',\n            );\n        }\n\n        if (PHP_VERSION_ID < 80400 && $nativeLazyObjects) {\n            throw new LogicException('Lazy loading proxies require PHP 8.4 or higher.');\n        }\n\n        $this->attributes['nativeLazyObjects'] = $nativeLazyObjects;\n    }\n\n    /**\n     * @deprecated lazy ghost objects are always enabled\n     *\n     * @return true\n     */\n    public function isLazyGhostObjectEnabled(): bool\n    {\n        return true;\n    }\n\n    /** @deprecated lazy ghost objects cannot be disabled */\n    public function setLazyGhostObjectEnabled(bool $flag): void\n    {","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Configuration.php#L651-L687","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\n$config = new Configuration();\n$config->enableNativeLazyObjects(true); // LogicException on PHP 8.3\n\n// after\n$config = new Configuration();\nif (PHP_VERSION_ID >= 80400) {\n    $config->enableNativeLazyObjects(true);\n}","handlingStrategy":"validation","validationCode":"if (PHP_VERSION_ID >= 80400) {\n    $config->enableNativeLazyObjects(true);\n} // else: keep default proxy-based lazy loading","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["doctrine-orm","php-version","lazy-loading","configuration"],"backgroundTag":"php-version-unsupported","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}