I have a class named ModelFactory
which is supposed to return an instance of Model
object. But for some reason, PHP can't seem to find it.
Warning: require_once(../../../../../model.php): failed to open stream: No such file or directory
Here's my ModelFactory
class which is loaded via DI for reference:
namespace jas\Pdf\Factory;
require_once "../../../../../model.php";
use Model;
class ModelFactory
{
/**
* @return Model
*/
public function create(){
return new Model(false);
}
}
And here's my Model
class, which is 5 levels above ModelFactory
class, loaded via require_once
:
class Model
{
public function __construct($serverRequest = false)
{
if(!$serverRequest){
$this->checkIfLocal();
}
$this->conn = $this->connectToDB();
}
}
I'm kind of confused. Is the PHP throwing the error due to Model
class not having a namespace, or is it because ModelFactory
namespace conflicting with the file paths? Thank you so much for any insights you can provide.