I'm using different versions of a similar library across several projects. The libraries are namespaced like this:
Project A:
namespace Ewout\Project_A\Compatibility;
Class Core {}
Project B:
namespace Ewout\Project_B\Compatibility;
Class Core {}
...etc
To avoid using the complete namespace everywhere, I alias them in the project's PHP files:
Project A (a/main.php):
use Ewout\Project_A\Compatibility\Core as CoreX;
Project B (b/main.php):
use Ewout\Project_B\Compatibility\Core as CoreX;
Is this ok? The project scripts can be loaded simultaneously although I would never need to alias the Project_A\Compatibility\Core
and Project_B\Compatibility\Core
class in the same file. There is noCoreX
class in the global namespace (from my tests it looks like that wouldn't cause any issues either though?).
I tested and haven't seen any errors from PHP complaining about conflicts yet, but want to make sure that this will not cause problems down the road.