I have a construct function where I am using include_path
, the function looks like this :
public function __construct()
{
$url = $this->parseUrl();
if(file_exists('application\controllers'.$url[0].'.php')){
$this->controller=$url[0];
unset($url[0]);
}
require_once 'application\controllers'.$this->controller.'.php';
echo $this->controller;
}
Unfortunately, when I try to load an existing controller url like this one http://localhost/project/public_html/home
I get the following error :
Warning: require_once(application\controllers home.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project\application\core\App.php on line 24
Fatal error: require_once(): Failed opening required 'application\controllers home.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project\application\core\App.php on line 24
I followed the documentation and I included the paths :
C:\xampp\htdocs\project\application
and
C:\xampp\htdocs\project\application\controllers
but I am still getting the error and I am just clueless why... can someone help me?
But you have a space in the path...is that normal? Can you try with 'application\controllers' (without space there) please? And controllershome.php is the name of file, or controllers/home.php?