Namespaces are only available as of 5.3
At least in the case of classes, you can use the class_exists
function to check if a class has already been defined with a like name within the global namespace. Coupled with the __autoload()
function, you can create one universal alias and have the system check for both classes named by the original name as well as the name with some kind of extra identifier prepended. I'll use "ns" as an example.
function __autoload($class){
try{
require_once('ns'.$class.'.php');
}catch(Exception $e){
echo 'The class is unavailable in pseudo-namespace as well as global';
}
}
Just make sure the require path points to wherever you keep your models. You could use a different folder instead of the alias as well.
This way, any duplicate classes can be put into files separate from the main execution that are only included if they don't exists in the global. Though this doesn't strictly fix the problem of having to physically rename the classes, it will allow you to put your definitions in different directories for versioning purposes etc.