Reputation: 781
At this moment, I use Symfony 3, and I don't have any problem in dev.
When I have put my website in prod, i have this error :
Attempted to load class "ZoneRepository" from namespace "AppBundle\Repository".
Did you forget a "use" statement for another namespace?
Code of the 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();
}
}
I tried :
use Doctrine\ORM\EntityRepository;
/**
* ZoneRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ZoneRepository extends EntityRepository
But it not works
Have you an idea ?
Thanks
Solution : You put all repositories files in your Entity fold. Don't forget change the
* @ORM\Entity(repositoryClass="AppBundle\Entity\ZoneRepository")
Upvotes: 2
Views: 17660
Reputation: 531
I had this error when my file name and class name is different.
Upvotes: 6
Reputation: 103
I had the same problem, check that the location of the files have the same path as your namespace
for example:
use UtilBundle\Entity\Base\BaseClass;
...
class TipoExpediente extends BaseClass {
and mi base class is in: /src/UtilBundle/Entity/Base/BaseClass.php
Upvotes: 4
Reputation: 1192
clear the cache and check, use
php app/console cache:clear --env=prod
php app/console cache:clear --env=dev
adjust file permission if necessary,dev environment cache is disabled for performance and ease of use, prod environment is optimized for speed
Upvotes: 0