【发布时间】:2023-03-21 02:05:01
【问题描述】:
我正在尝试调试第 15 行中的错误“致命错误:无法在 C:\wamp\www\Symfony\src\Acme\UserBundle\entity\User.php 中重新声明类 Acme\UserBundle\Entity\User”当我想使用 Doctrine 命令“php app/console dictionary:schema:update --force”创建 Mysql 表时,我的命令窗口。
这是我的实体代码的顶部:
namespace Acme\UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Acme\UserBundle\Entity\User
*
* @ORM\Table(name="acme_users")
* @ORM\Entity(repositoryClass="Acme\UserBundle\Entity\UserRepository")
*/
class User implements UserInterface, \Serializable
{
//...
为了查看我可以在哪里双重声明我的“用户”类,我已将其重命名为“用户别名”并清除了我的缓存(使用“php app/console cache:clear”命令)。然后命令窗口给我错误“名称为'basededonne.acme_users'的表已经存在。'。但是,我在phpmyadmin中看不到这个表。此外,我的浏览器给我错误“User.php行中的FatalErrorException 15:编译错误:无法重新声明类 Acme\UserBundle\Entity\User_alias”(当我使用“User”类时,我的浏览器中没有错误)。
谁能给我一些其他的选择来探索解决这个问题?我猜我目前缺少一幅更大的图景。
【问题讨论】:
-
一种可能是您使用另一个文件名备份了 User.php。所以用类 User 搜索整个项目,如果有的话?重命名它。并手动删除缓存,然后更新您的架构。