I have a few PHP classes which are defined like this:
module1Model.php
namespace App\Modules\module1\models;
class module1Model
{
//... methods etc.
}
module2Model.php
namespace App\Modules\module2\models;
class module2Model
{
//... methods etc.
}
In some other class i want to use those namespaces. So i placed the following lines at the top of my page:
someClass.php
namespace App\Modules\someClass\controllers;
use App\Modules\module1\models; // Works
use App\Modules\module2\models; // Fails
use Core\Logger\TextLogger; // Works
class somceClass
{
//... methods etc.
}
So in someClass i'm trying to use both module1 and module2 models. Which are technically not in the same namespace. Just partially. But why is it giving me an error about it then..??
And what would be a good way to solve this problem? I know i can add this to the second line:
use App\Modules\module2\models as module2; // Now works
But i don't really like to do it that way, since i didn't do it like that in all my other classes (using the as keyword). That feels so inconsistent.
Is there any other way to make this work..? Or am i really forced to use the as keyword in all my use declarations...? :-(