I'm running a one instance Apache setup with multiple virtual hosts that runs different versions of the same code base.
By this I mean that one virtual host can server one version of a class and another can server second version of the same class (same namespace, same name).
/file/path/host-a/MyClass.php
/file/path/host-b/MyClass.php
Sometimes I get an exception that shows me that one of the virtual hosts uses the "wrong" version of a class. E.g. on host b I get an exception with file path to script of /file/path/host-a/MyClass.php
I thought that the APC optcode cache used the file path, at least as a part of the key, but I'm fearing, that it only uses a qualified class name like:
My\Namespace\MyClass
Is that the case? Please point to any documentation on this subject if possible.
Though is was unable to find any documentation on the answer to this question php - APC opcode caching on different file versions explains that the APC optcode cache in fact does use the path of the file that defines the class to distinguis classes with the same name.
After @hakra pointed out to me the behaviour of APC, I was able focus my efforts on the class loader. My class loader uses memcached
as cache for storing the class paths. It turned out that the code for building cache keys were the cause of the problem - and not the APC which it seemed to be.
So should you be in a similar situation where your see that the incorrect "versions" of a class is loaded ensure that you class loader is working as expected. One obvious clue is of course the file path of the problem class.