gpt4 book ai didi

php - 您是否忘记了另一个命名空间的 "use"语句?

转载 作者:行者123 更新时间:2023-12-03 22:53:09 25 4
gpt4 key购买 nike

此时,我使用的是 Symfony 3,在开发中没有任何问题。

当我将我的网站投入生产时,我遇到了这个错误:

Attempted to load class "ZoneRepository" from namespace "AppBundle\Repository".
Did you forget a "use" statement for another namespace?

ZoneRepository 代码:

<?php

namespace AppBundle\Repository;

/**
* ZoneRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ZoneRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @return array
*/
public function getZones()
{
$qb = $this->createQueryBuilder('z');

$qb
->select('z')
->where('z.active = 1')
->orderBy('z.id', 'DESC');

return $qb->getQuery()->getResult();
}
}

img of my stucture

我试过了:

use Doctrine\ORM\EntityRepository;

/**
* ZoneRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ZoneRepository extends EntityRepository

但是不行

你有想法吗?

谢谢


解决方案:您将所有存储库文件放在实体文件夹中。不要忘记更改

* @ORM\Entity(repositoryClass="AppBundle\Entity\ZoneRepository")

最佳答案

当我的文件名和类名不同时出现此错误。

关于php - 您是否忘记了另一个命名空间的 "use"语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38214789/

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