views:

34

answers:

3

I have a problem, where I have two third party libraries classes that I have to extend and use together. But both have the same naming convention and two class name end up having the same name.

Since I cannot extend two classes, I don't know how to fix them, how to create a wrapper against one. I cannot use PHP Namespaces as the PHP version is just 5.2.10 and not 5.3.

What options I have?

+1  A: 

That's the trouble when you don't have namespaces.

The only option you have is to go through the code of one or the other, and change all the class names. Perhaps add a prefix to both of them that makes it clear which one is which.

Spudley
+1  A: 

This is exactly the problem that PHP namespaces are intended to solve. There is no clean way to do this pre-5.3. The best you can do is to rename one or both and go through the libraries correcting the calls. This is a pain, but, as they are separate libraries, this shouldn't be too difficult.

My other suggestion would be to make sure that installing 5.3 really is impossible. It is by far the best solution to your problem.

lonesomeday
A: 

I think you can implement rpc like interface, for one class. For other you can extend and use. http://en.wikipedia.org/wiki/Remote_procedure_call

nerkn