gpt4 book ai didi

php - Symfony3 错误命名空间不包含任何映射实体

转载 作者:可可西里 更新时间:2023-10-31 23:38:14 26 4
gpt4 key购买 nike

我尝试在 Symfony 3.0.1 中生成 getter 和 setter

当我运行命令时

php bin/console doctrine:generate:entities VendorName/MyBundle/EntityName

我有错误

Namespace "VendorName\MyBundle\EntityName" does not contain any mapped entities.

错在哪里?

Edit-1:首先生成YAML格式的实体

Edit-2:我尝试为供应商包生成 getter 和 setter

我也尝试使用命令 php bin/console doctrine:generate:entities VendorNameMyBundle:EntityName 并出现另一个错误:

Can't find base path for "VendorName\MyBundle\Entity\EntityName" (path: "/home/site/vendor/vendorname/mybundle/Entity", destination: "/home/site/vendor/vendorname/mybundle/Entity").  

最佳答案

作为John Pancoast在他的 answer 中指出另一个问题:

Doctrine does not support PSR-4 when doing anything with code generation. It has to do with how they map class namespaces to filesystem paths and how PSR-4 allows class/namespace paths that don't directly map to the filesystem.

https://github.com/doctrine/DoctrineBundle/issues/282

阐明解决错误消息到底需要什么;您必须编辑 bundle 的 composer.json 文件,并更改 bundle 的文件夹结构。

composer.json 中将 psr-4 更改为 psr-0:

"autoload": {
"psr-4": { "Acme\\Bundle\\AwesomeBundle\\": "" }
},

到:

"autoload": {
"psr-0": { "Acme\\Bundle\\AwesomeBundle\\": "" }
},

更改包的文件夹结构:

vendor
+--acme
+--awesome-bundle
|--Controller
|--Entity

到:

vendor
+--acme
+--awesome-bundle
+--Acme
+--Bundle
+--AwesomeBundle
|--Controller
|--Entity

以下命令将不再抛出异常:

bin/console doctrine:generate:entities AwesomeBundle

关于php - Symfony3 错误命名空间不包含任何映射实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34918424/

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