gpt4 book ai didi

php - Symfony 5 - make :entity 仅支持属性映射

转载 作者:行者123 更新时间:2023-12-05 01:50:27 26 4
gpt4 key购买 nike

我从今天开始就有这个问题,我不知道是什么原因造成的。似乎也找不到有此问题的人:/

我的 Composer json

"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.209",
"aws/aws-sdk-php-symfony": "^2.2",
"beberlei/doctrineextensions": "^1.3",
"composer/package-versions-deprecated": "~1.11.99.4",
"doctrine/annotations": "^1.13",
"doctrine/doctrine-bundle": "^2.5",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.10",
"easycorp/easyadmin-bundle": "^4.0",
"firebase/php-jwt": "^6.1",
"friendsofsymfony/rest-bundle": "^3.3",
"jms/serializer": "^3.17",
"jms/serializer-bundle": "^4.0",
"lexik/jwt-authentication-bundle": "~2.14.4",
"nelmio/api-doc-bundle": "^4.9",
"nelmio/cors-bundle": "^2.2",
"oneup/flysystem-bundle": "^4.3",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.2",
"sensio/framework-extra-bundle": "^6.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.4.*",
"symfony/console": "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/messenger": "5.4.*",
"symfony/mime": "5.4.*",
"symfony/monolog-bundle": "^3.1",
"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": "^6.0",
"symfony/security-bundle": "5.4.*",
"symfony/sendinblue-mailer": "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/yaml": "5.4.*",
"tattali/mobile-detect-bundle": "^2.2",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0",
"vich/uploader-bundle": "^1.19",
"zircote/swagger-php": "^4.4"
},
"require-dev": {
"ext-xdebug": "^3.1.0",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "5.4.*",
"symfony/css-selector": "5.4.*",
"symfony/debug-bundle": "5.4.*",
"symfony/maker-bundle": "^1.36",
"symfony/phpunit-bridge": "^6.0",
"symfony/stopwatch": "5.4.*",
"symfony/web-profiler-bundle": "5.4.*"
},
"config": {
"allow-plugins": {
"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"
],
"compile": [
"php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": true,
"require": "5.4.*"
}
}

错误:

[错误] make:entity 仅支持属性映射,但 App\Entity\Test 类使用不同的格式。如果您希望此命令生成属性和 getter/setter 方法,请添加您的映射
配置,然后使用 --regenerate 标志重新运行此命令。

Doctrine .yaml

doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'

# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App

我见过很多人遇到相反的问题,错误显示“仅注释”,但我的情况并非如此。

谢谢你的帮助我现在真的需要这个运行因为这个学校项目下周到期:/

[编辑] 这是由 doctrine 创建的失败实体的代码

    <?php

namespace App\Entity;

use App\Repository\TestRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column()]
private ?int $id = null;

public function getId(): ?int
{
return $this->id;
}
}

最佳答案

就像他们说的那样here (和 here ),MakerBundle 的开发人员从 MakerBundle 中的 v1.44 开始有意删除注释支持,以支持 PHP 8 对使用属性的元数据的 native 支持。

将来,您将不得不迁移到新系统,但目前您可以将 MakerBundle 降级到 1.43。为此,您可以发送:

composer require 'symfony/maker-bundle:1.43'

我希望 Symfony 能让迁移到新系统变得容易。

关于php - Symfony 5 - make :entity 仅支持属性映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73073080/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com