目前,我使用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
但这行不通
你有主意吗?
谢谢
解决方案:
您将所有存储库文件都放在Entity文件夹中。别忘了更改
* @ORM\Entity(repositoryClass="AppBundle\Entity\ZoneRepository")
参考方案
我遇到了同样的问题,请检查文件的位置是否与名称空间相同
例如:
use UtilBundle\Entity\Base\BaseClass;
...
class TipoExpediente extends BaseClass {
和mi基本类位于:/src/UtilBundle/Entity/Base/BaseClass.php
Symfony 2在用户站点上动态添加字段以形成表单 - php我正在研究调查包。目的是为用户提供一个功能全面的调查系统。我已经准备好一个后端,使您可以创建调查,添加问题(打开文本,单选按钮,复选框),是否需要提问,激活调查,生成令牌以及通过电子邮件将令牌发送到调查的链接。当然,我也有显示调查并保存答案的前端。现在,我想添加另一种可能性。带有答案(单选或复选框)和评论的问题。例如:你有一只狗吗?是没有如果用户选择是,则附…
PHP strtotime困境 - php有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00…
PHP-将日期插入日期时间字段 - php我已在数据库中使用datetime字段存储日期,使用PHP将“今天的日期”插入该字段的正确方法是什么?干杯, 参考方案 我认为您可以使用php date()函数
PHP-全局变量的性能和内存问题 - php假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…
PHP-如何获取类的成员函数列表? - php如果我知道班级的名字。有没有办法知道类的成员函数列表? 参考方案 get_class_methods()是你的朋友