This problem meets me after upload my Symfony2 app from my laptop to production server. Then, when I try run app I get:
Symfony2, Doctrine2 Fatal error: Call to a member function getMetadataFactory() on a non-object in…
After lot of searching I found solution. In my case was eAccelerator on production server.
In default configuration eAccelerator remove comments (and – of course – annotations from Entity definition class) probably to speed execution code. This is a reason for this error.
You have two options: say good bay to eAccelerator or compile it with
--with-eaccelerator-doc-comment-inclusion=yes
switch.
So step by step second solution:
/usr/local/php5/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php5/bin/php-config --with-eaccelerator-doc-comment-inclusion=yes
make
make install
That`s it! Have a nice day 🙂