10

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

2
  • 2
    looks like inside the file its written small e.g -> class accountRepository {} Commented Jun 17, 2014 at 16:21
  • I have nothing special in this file Commented Jul 3, 2014 at 8:54

6 Answers 6

6
+50

Intent to var_dump($name) and var_dump($class) and strcasecmp($name, $class) to see why you enter in the condition.

Sign up to request clarification or add additional context in comments.

Comments

3

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 { ... })

Comments

3

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")

Comments

1

This is a known bug in Symfony2 :

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

It has been merged in 2.5 but not tagged yet (source)

To check if this is really the case for you, you might want to try modifying the src/Symfony/Component/Debug/DebugClassLoader.php file manually :

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

... and check if you still have the problem after clearing your cache

2 Comments

I have already try this thing, and i always have this error ;)
In your error, it doesn't say "in file_XX at line YY" to try to track down the problem ?
1

Please Add this if condition in DebugClassLoader.php File at 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));
        } 
    }

It will solve your problem

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

thanks

Comments

1

Your controller name first word is lowercase in your routing.yml

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

like teacher..

will be Teacher

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.