【发布时间】:2016-11-07 23:03:52
【问题描述】:
目前,我使用的是 Symfony 3,我在开发中没有任何问题。
当我将我的网站放入 prod 时,我遇到了这个错误:
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();
}
}
我试过了:
use Doctrine\ORM\EntityRepository;
/**
* ZoneRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ZoneRepository extends EntityRepository
但它不起作用
你有想法吗?
谢谢
解决方案: 您将所有存储库文件放在 Entity 折叠中。不要忘记更改
* @ORM\Entity(repositoryClass="AppBundle\Entity\ZoneRepository")
【问题讨论】:
-
您是否清除了 prod env 的缓存?
-
你能告诉我们实体文件是什么样的吗?可能存在一些参考问题
-
您确定文件名使用相同的大小写吗?当您在 windows 上使用 dev 模式和在 linux 上使用 prod 模式时,这通常会附加。
-
是的,您可以查看结构的 img 名称为:AppBundle/Repository 中的“ZoneRepository”
-
我已经通过composer生成了存储库,你有什么想法吗?