doctrineHelper.php 執行 make:entity symfony 指令時拋出錯誤
P粉420868294
P粉420868294 2024-03-26 00:19:26
0
1
377

我正在嘗試使用命令列 php bin/console make: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

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.*"
    }
}

P粉420868294
P粉420868294

全部回覆(1)
P粉748218846

此問題是由新發布的 Doctrine ORM 2.12.0 觸發的

在 Symfony 或 Doctrine 推送修復之前(還沒有時間檢查哪個包「有問題」),您可以降級到 Doctrine ORM 2.11.3。

在您的 composer.json 中更改以下行:

"doctrine/orm": "^2.12",

至:

"doctrine/orm": "^2.11",

並修改您的 conflict 部分,以便不會安裝 2.12:

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

此後,執行composer updatedoctrine/orm來降級軟體包,bin/console make:entity應該會再次工作。


我發現該問題已報告給 symfony/maker-bundle幾天前。監控此問題是了解何時可以升級 Maker 捆綁包並從配置中刪除 doctrine/orm 衝突聲明的好方法。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!