加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 16:00:21 所属栏目:PHP教程 来源:网络整理
导读:我尝试在Symfony 3.0.1中生成getter和setter 当我运行命令 php bin/console doctrine:generate:entities VendorName/MyBundle/EntityName 我有错误 Namespace "VendorNameMyBundleEntityName" does not contain any mapped entities. 哪里出错了? 编辑-1
我尝试在Symfony 3.0.1中生成getter和setter

当我运行命令

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

我有错误

Namespace "VendorNameMyBundleEntityName" does not contain any mapped entities.

哪里出错了?

编辑-1:首先生成具有YAML格式的实体

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

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

Can't find base path for "VendorNameMyBundleEntityEntityName" (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.

07002

澄清解决错误消息所需的确切内容;您必须编辑bundle的composer.json文件,并更改bundle的文件夹结构.

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

"autoload": {
    "psr-4": { "AcmeBundleAwesomeBundle": "" }
},

至:

"autoload": {
    "psr-0": { "AcmeBundleAwesomeBundle": "" }
},

更改bundle的文件夹结构:

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

至:

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

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

bin/console doctrine:generate:entities AwesomeBundle

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读