{"record":{"id":"d9be3ebc3ddedd50","repo":"doctrine/orm","slug":"proxy-directory-cannot-be-null","errorCode":null,"errorMessage":"Proxy directory cannot be null","messagePattern":"Proxy directory cannot be null","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Tools/Console/Command/GenerateProxiesCommand.php","lineNumber":66,"sourceCode":"                'https://github.com/doctrine/orm/pull/12005',\n                'Generating proxies is deprecated and will be impossible in Doctrine ORM 4.0.',\n            );\n        }\n\n        $ui = (new SymfonyStyle($input, $output))->getErrorStyle();\n\n        $em = $this->getEntityManager($input);\n\n        $metadatas = $em->getMetadataFactory()->getAllMetadata();\n        $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));\n\n        // Process destination directory\n        $destPath = $input->getArgument('dest-path');\n        if ($destPath === null) {\n            $destPath = $em->getConfiguration()->getProxyDir();\n\n            if ($destPath === null) {\n                throw new InvalidArgumentException('Proxy directory cannot be null');\n            }\n        }\n\n        if (! is_dir($destPath)) {\n            mkdir($destPath, 0775, true);\n        }\n\n        $destPath = realpath($destPath);\n\n        if (! file_exists($destPath)) {\n            throw new InvalidArgumentException(\n                sprintf(\"Proxies destination directory '<info>%s</info>' does not exist.\", $em->getConfiguration()->getProxyDir()),\n            );\n        }\n\n        if (! is_writable($destPath)) {\n            throw new InvalidArgumentException(\n                sprintf(\"Proxies destination directory '<info>%s</info>' does not have write permissions.\", $destPath),","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Tools/Console/Command/GenerateProxiesCommand.php#L48-L84","documentation":"orm:generate-proxies writes proxy classes either to the dest-path argument or, when that is omitted, to the directory configured on the EntityManager (Configuration::getProxyDir(), which defaults to null when never set). Running the command without an argument on such an unconfigured EntityManager throws InvalidArgumentException('Proxy directory cannot be null') before any work happens.","triggerScenarios":"Running orm:generate-proxies without a dest-path argument when the Configuration never called setProxyDir() — typical with hand-rolled Configuration objects; setups relying on ORMSetup's temp-dir default but constructing Configuration directly.","commonSituations":"ORM 2 to 3+ upgrades where nothing assumes a proxy directory anymore; custom EntityManager factories; CI jobs that regenerate proxies on a minimal configuration.","solutions":["Pass the destination explicitly: php bin/console orm:generate-proxies var/cache/prod/doctrine/orm/Proxies.","Or configure it once: $config->setProxyDir(__DIR__.'/var/cache/prod/doctrine/orm/Proxies') (doctrine-bundle: orm.proxy_dir).","Prefer ORMSetup::createAttributeMetadataConfiguration(), which fills proxyDir with sys_get_temp_dir() when null is given."],"exampleFix":"// before\n$config = new Configuration(); // proxyDir stays null\n$ php bin/console orm:generate-proxies\n// InvalidArgumentException: Proxy directory cannot be null\n\n// after\n$config = ORMSetup::createAttributeMetadataConfiguration($paths, $devMode,\n    proxyDir: __DIR__ . '/var/cache/prod/doctrine/orm/Proxies');","handlingStrategy":"validation","validationCode":"if ($em->getConfiguration()->getProxyDir() === null) {\n    throw new LogicException('Configure the proxy directory (setProxyDir) before generating proxies.');\n}\n// run orm:generate-proxies","typeGuard":null,"tryCatchPattern":"Catch \\InvalidArgumentException around the command in build scripts and fail with an actionable message: 'set proxy_dir (doctrine.orm.proxy_dir) or pass a dest-path argument'.","preventionTips":["Create Configuration via ORMSetup::create* helpers so the proxy directory defaults sensibly.","Set orm.proxy_dir explicitly in Symfony config.","Add a bootstrap assertion that getProxyDir() !== null in environments that generate proxies."],"tags":["doctrine-orm","console","proxy","configuration","cli"],"backgroundTag":"missing-configuration-path","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}