If i've different version of same third-party library ( or class ) that have of course same namespaces and class names. Is there a way to include them in same project avoiding name collisions?
Another case for this issue happens when we've a modular project where components are developed separately . So we can have different modules that includes same external library file in their own folder, but of course when modules will be loaded , we have a class collision.
in this article Loading multiple versions of the same class
an user suggests to use this code:
namespace old {
include /lib/api-1.0/library.php;
}
namespace foo {
include /lib/api-2.0/library.php;
}
$oldlibary = new old\Library();
$newlibrary = new foo\Library();
but of course it doesn't work. Classes collides anyway because they are declared gobally instead of vars.
So..is there another solution that is not hand-edit all the namespace of libraries to include?
thanks in advance