Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 error : Case mismatch between loaded and declared class names:

Tags:

symfony

I'm working on Symfony2 and i updated my project with composer.phar update

Now, when i check my site with app_dev.php i always have this error :

Case mismatch between loaded and declared class names: Blu\ProjectBun
  dle\Entity\AccountRepository vs Blu\ProjectBundle\Entity\AccountRepos
  itory

It's the same when i clear the dev cache, manually or not. I have nothing special in AccountRepository.php..

Any ideas ?

Edit : I already tried to add if ($name !== $class && 0 === strcasecmp($name, $class)) { in DebugClassLoader.php and no effect

like image 568
Clément Andraud Avatar asked Jun 17 '14 15:06

Clément Andraud


2 Answers

I had this problem and after trying all the solutions I found, no one of them worked for me. I am working with Symfony 2.8, Doctrine ORM and Sonata Admin Bundle and this exception appeared when I added an admin class (for a class related with the class showed in the exception message) and I tried to open it.

My mistake was I wrote the name of the database tables in lowercase in Doctrine annotations in the class related, check if you have it in uppercase:

ORM\ManyToOne(targetEntity="Product")
like image 164
rsister88 Avatar answered Sep 19 '22 16:09

rsister88


though the answer was a typo in the class namespace, this errors occurs also if your entity is defined via xml, i.e. User.orm.xml, and you accidentally name the file lower-case, this will drive nuts the xml loader

  1. create FooNamespace\BarBundle\Resources\config\User.orm.xml

  2. create FooNamespace\BarBundle\Entity\User.php (class User { ... })

like image 44
ROLO Avatar answered Sep 20 '22 16:09

ROLO