make:entity symfony命令在doctrinehelper.php中给出错误

发布于 2025-01-22 21:02:07 字数 3675 浏览 2 评论 0 原文

我正在尝试使用命令行 php bin/Console制作:Entity

,但它一直给我这个错误:

In DoctrineHelper.php line 187:

  Cannot access protected property Doctrine\ORM\Mapping\Driver\AnnotationDriver::$classNames


make:entity [-a|--api-resource] [-b|--broadcast] [--regenerate] [--overwrite] [--] [<name>]

我遵循官方网站指令下载所有要求 https://symfony.com/doc/5.4/doctrine.html

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.6",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/orm": "^2.12",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.4",
        "sensio/framework-extra-bundle": "^6.1",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.4.*",
        "symfony/console": "5.4.*",
        "symfony/doctrine-messenger": "5.4.*",
        "symfony/dotenv": "5.4.*",
        "symfony/expression-language": "5.4.*",
        "symfony/flex": "^1.17|^2",
        "symfony/form": "5.4.*",
        "symfony/framework-bundle": "5.4.*",
        "symfony/http-client": "5.4.*",
        "symfony/intl": "5.4.*",
        "symfony/mailer": "5.4.*",
        "symfony/mime": "5.4.*",
        "symfony/monolog-bundle": "^3.0",
        "symfony/notifier": "5.4.*",
        "symfony/process": "5.4.*",
        "symfony/property-access": "5.4.*",
        "symfony/property-info": "5.4.*",
        "symfony/proxy-manager-bridge": "5.4.*",
        "symfony/runtime": "5.4.*",
        "symfony/security-bundle": "5.4.*",
        "symfony/serializer": "5.4.*",
        "symfony/string": "5.4.*",
        "symfony/translation": "5.4.*",
        "symfony/twig-bundle": "5.4.*",
        "symfony/validator": "5.4.*",
        "symfony/web-link": "5.4.*",
        "symfony/webapp-meta": "^1.0",
        "symfony/webpack-encore-bundle": "^1.12",
        "symfony/yaml": "5.4.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "config": {
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.4.*"
        }
    },
    "require-dev": {
        "symfony/debug-bundle": "5.4.*",
        "symfony/maker-bundle": "^1.38",
        "symfony/stopwatch": "5.4.*",
        "symfony/web-profiler-bundle": "5.4.*"
    }
}

I'm trying to make an entity User using the command line php bin/console make:entity

But it keeps giving me this error:

In DoctrineHelper.php line 187:

  Cannot access protected property Doctrine\ORM\Mapping\Driver\AnnotationDriver::$classNames


make:entity [-a|--api-resource] [-b|--broadcast] [--regenerate] [--overwrite] [--] [<name>]

I have followed the official website instructions to download all the requirements https://symfony.com/doc/5.4/doctrine.html

composer.json:

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.6",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/orm": "^2.12",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.4",
        "sensio/framework-extra-bundle": "^6.1",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.4.*",
        "symfony/console": "5.4.*",
        "symfony/doctrine-messenger": "5.4.*",
        "symfony/dotenv": "5.4.*",
        "symfony/expression-language": "5.4.*",
        "symfony/flex": "^1.17|^2",
        "symfony/form": "5.4.*",
        "symfony/framework-bundle": "5.4.*",
        "symfony/http-client": "5.4.*",
        "symfony/intl": "5.4.*",
        "symfony/mailer": "5.4.*",
        "symfony/mime": "5.4.*",
        "symfony/monolog-bundle": "^3.0",
        "symfony/notifier": "5.4.*",
        "symfony/process": "5.4.*",
        "symfony/property-access": "5.4.*",
        "symfony/property-info": "5.4.*",
        "symfony/proxy-manager-bridge": "5.4.*",
        "symfony/runtime": "5.4.*",
        "symfony/security-bundle": "5.4.*",
        "symfony/serializer": "5.4.*",
        "symfony/string": "5.4.*",
        "symfony/translation": "5.4.*",
        "symfony/twig-bundle": "5.4.*",
        "symfony/validator": "5.4.*",
        "symfony/web-link": "5.4.*",
        "symfony/webapp-meta": "^1.0",
        "symfony/webpack-encore-bundle": "^1.12",
        "symfony/yaml": "5.4.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "config": {
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.4.*"
        }
    },
    "require-dev": {
        "symfony/debug-bundle": "5.4.*",
        "symfony/maker-bundle": "^1.38",
        "symfony/stopwatch": "5.4.*",
        "symfony/web-profiler-bundle": "5.4.*"
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时光的容颜 2025-01-29 21:02:07

该问题是由新发布的学说ORM 2.12.0触发的

,直到通过Symfony或Doctrine推动修复程序(还没有时间检查哪个软件包是“故障”),您可以降级到Doctrine Orm 2.11。 3。

在您的 Composer.json 中更改行:

 "doctrine/orm": "^2.12",

TO:

 "doctrine/orm": "^2.11",

并修改您的冲突节,以使2.12无法安装:

"conflict": {
      "symfony/symfony": "*",
      "doctrine/orm": "2.12.0"
    },

此后,运行 COMPOSER COMPOSER UPDATE/ORM 要降级软件包, bin/Console Make:Entity 应该再次工作。


我看到这个问题已报告给Symfony/Maker-Bundle 几天前。监视此问题将是知道何时可以升级制造商捆绑包并删除 Doctrine/orm 冲突声明的好方法。

This issue was triggered by the newly released Doctrine ORM 2.12.0

Until a fix is pushed, either by Symfony or Doctrine (haven't had time yet to check which package is "at fault"), you can downgrade to Doctrine ORM 2.11.3.

In your composer.json change the line:

 "doctrine/orm": "^2.12",

to:

 "doctrine/orm": "^2.11",

And modify your conflict section so that 2.12 does not get installed:

"conflict": {
      "symfony/symfony": "*",
      "doctrine/orm": "2.12.0"
    },

After this, run composer update doctrine/orm to downgrade the package, and bin/console make:entity should work again.


I see that the issue has been reported to symfony/maker-bundle some days ago. Monitoring this issue would be a good way to know when you can upgrade the Maker bundle and remove the doctrine/orm conflict declaration from your configuration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文