gpt4 book ai didi

php - Maker Bundle 仅支持注释映射

转载 作者:行者123 更新时间:2023-12-04 13:08:42 25 4
gpt4 key购买 nike

我已经更改了我的 Symfony 项目的配置,以便在我的实体中使用带有 Doctrine 的 PHP 属性。我对此感到非常高兴,并想尝试一下。
我换了 doctrine.yaml来自 annotationattribute

 orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
并在我的实体中使用属性
#[ORM\Entity(UserRepository::class)]
class User implements UserInterface
{
#[ORM\Id()]
#[ORM\GeneratedValue()]
#[ORM\Column(type: "integer")]
private ?int $id;

#[ORM\Column(type: "string", length: 180, unique: true)]
private ?string $email;

#[ORM\Column(type: "json")]
private array $roles = [];
}
有了这个配置,我的 php bin/console do:sc:up -f效果很好。
但是当我尝试用 php bin/console make:entity 生成一个新实体时我收到此错误:

[ERROR] Only annotation mapping is supported by make:entity, but theApp\Entity\Toto class uses a differentformat. If you would like this command to generate the properties & getter/setter methods, add your mapping
configuration, and then re-run this command with the --regenerate flag.


似乎还不可能使用 maker 生成具有属性的实体。
有没有人找到解决这个问题的方法,还是我们只需要等待新版本?
现在我正在使用:
"doctrine/annotations": "1.13.1"
"doctrine/doctrine-bundle": "2.4.2",
"doctrine/orm": "2.9.3"
"symfony/maker-bundle": "1.31.1",

最佳答案

目前,它不受支持。有an issue创建要求此,尽管我 120% 确定开发人员已经了解 PHP 属性,并且此功能将尽可能完成。
同时,您可以手动创建实体,而无需使用 maker(并不难),甚至可以使用类似 Rector 的东西。将注释转换为属性。有a built-in rule为了那个原因。

关于php - Maker Bundle 仅支持注释映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67992823/

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