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

I am working on Symfony2 and I updated my composer.phar update project

Now when I check my site using 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 

Same thing when I clear the dev cache, manually or not. I have nothing special in AccountRepository.php ..

Any ideas?

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

+7
symfony
source share
6 answers

Intent on var_dump ($ name) and var_dump ($ class) and strcasecmp ($ name, $ class) to understand why you are entering a condition.

+5
source share

although the answer was a typo in the class namespace, these errors also occur if your entity is defined via xml, i.e. User.orm.xml, and you accidentally name the file lowercase, this will disable the xml loader

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

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

+2
source share

This is a known bug in Symfony2:

https://github.com/symfony/symfony/commit/8e9cc35

It was merged in 2.5, but not marked ( source )

To check if this is true, you can try manually modifying the src/Symfony/Component/Debug/DebugClassLoader.php :

 // Line 178 if ($name !== $class && 0 === strcasecmp($name, $class)) { 

... and check if you have a problem after clearing the cache

+1
source share

Add this if the condition in the DebugClassLoader.php file is on line 177

  if ($name === $class) { if ($name !== $class && 0 === strcasecmp($name, $class)) { throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name)); } } 

This will solve your problem.

Location: root\Projectname\Symfony\vendor\symfony\symfony\src\Symfony\Component\Debug

thanks

+1
source share

I had this problem, and after I tried all the solutions that I found, none of them worked for me. I work with Symfony 2.8, Doctrine ORM, and Sonata Admin Bundle, and this exception came up when I added an admin class (for the class associated with the class specified in the exception message) and I tried to open it.

My mistake was that I wrote the name of the database tables in lowercase in the Doctrine annotations in the related class, check if you have this in upper case:

 ORM\ManyToOne(targetEntity="Product") 
+1
source share

The name of your controller is the name of the first word in your routing.yml

 usr_teacher_new: path: /new defaults: { _controller: CoreUserBundle:teacher:newteacher } 

as a teacher ..

will be t eacher

+1
source share

All Articles