Previous Blogs



Fatal Error: 'Class is not a valid entity or mapped super class.' in Doctrine 2

Posted by Elsabe on October 17, 2011

Wanted to quickly push some code onto a remote server for a client to test / review some functionality  and I got a real nasty looking exception on the front page, from the Doctrine 2 Mapper.

Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 
'Class models\LoginAttempts is not a valid entity or mapped super class.' in 
Stack trace: #0
'models\LoginAtt...') #1
models\LoginAtt...', Object(Doctrine\ORM\Mapping\ClassMetadata)) #2 
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata('models\LoginAtt...') #3 
Doctrine\ORM\Mapping\ClassMetadataFactory->getMeta in 
on line 137

The code base worked perfectly on localhost, but broke on remote. Joy in a jam jar!

Couldn't find a conclusive answer on the interwebs, and was about to give up when I noticed eAccelerator was installed on the server. Disabling eAccelerator did the trick! Turns out that eAccelerator strips away PHP doc blocks, which makes Doctrine 2's annotation mapping freak out completely.

Disable eAccelerator:

Add the following two lines in your htaccess file in the root of the web dir.

php_flag eaccelerator.enable 0
php_flag eaccelerator.optimizer 0

So now that I know what's wrong I've found a bunch of forum posts that would've helped. Nice post explaining eAccelerator and Doctrine 2 not playing well together at


  • CodeIgniter
  • Doctrine
  • PHP


Leave a Reply

(Your email will not be publicly displayed.)

Please type the letters and numbers shown in the image.Captcha CodeClick the image to see another captcha.