在symfony 4中生成实体(方法) [英] Generate entity in symfony 4 (methods)

查看:152
本文介绍了在symfony 4中生成实体(方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在symfony 4.0.6中运行命令 php bin / console doctrine:generate:entities App:Center 时,出现此错误:

when I tried to run the command php bin/console doctrine:generate:entities App:Center in symfony 4.0.6 I get this error:


找不到 App\Entity\Center的基本路径(路径:
/ home / USER / foo / bar / src / Entity,
目的地: / home / USER / foo / bar / src / Entity)。

Can't find base path for "App\Entity\Center" (path: "/home/USER/foo/bar/src/Entity", destination: "/home/USER/foo/bar/src/Entity").

中心是我的实体名称!

the Center is my entity name!

我该如何解决?

推荐答案

Doctrine开发人员不赞成Symfony 4的生成命令。之所以对您不起作用,是因为该命令是硬连线的在
projectRoot / src / {namespace} / {App} Bundle / Entity / {Center.php}
下找到目标目录,但是Symfony 4目录结构与此不同,因此无法找到它。如果您对使用命令一无所知,则可以扩展它并创建自己的命令,在其中可以更改实体的目标路径。您可以只跳过命令部分并自行生成getter和setter。

Doctrine developers are deprecating the generation commands for Symfony 4. The reason why it doesn't work for you is because the command is hardwired to find the destination directory under projectRoot/src/{namespace}/{App}Bundle/Entity/{Center.php} but the Symfony 4 directory structure is different than that, hence it cannot find it. If you are dead-set on using the command, you could probably extend it and create your own, in which you could change the destination path(s) for your entities. You can just skip the command part and generate getters and setters on your own.

教义问题: https:// github.com/doctrine/DoctrineBundle/issues/729

Symfony问题: https://github.com/symfony/symfony-docs/issues/8893

Symfony issue: https://github.com/symfony/symfony-docs/issues/8893

来自主义的维护者:
https://github.com/doctrine/DoctrineBundle/pull / 790

这篇关于在symfony 4中生成实体(方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆