PHP Error: Trying to clone an uncloneable object of class ReflectionClass

August 11, 2009 – 7:35 am

I’ve recently run into this error when deploying symfony applications:

“Trying to clone an uncloneable object of class ReflectionClass”.

What’s causing this is a relatively common setting in php.ini, called “zend.ze1_compatibility_mode”, which enables php4 compatibility mode in php5. Specifically it affects a couple of object handling conventions (empty objects cast to FALSE, and - oh this is my favorite - objects are passed by value instead of by reference.. can you imagine how much fun debugging your php5 application would be if this setting didn’t actually save you by breaking things altogether?) Needless to say some hosts like to keep this turned on to me “more compatible” with the past. Also needless to say I hate some hosts.

The way around it is either changing the php.ini setting to:


or disabling it at runtime, before the application bootstraps, via:

ini_set("zend.ze1_compatibility_mode", "off");

Hope it helps someone.

Filed under: Rnadom Sftuf — Tags: — by Richtermeister

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress