C:\xampp\htdocs contains Controller.php and ApplicationHelper.php. C:\xampp\htdocs\site contains index.php.
Here is the error I am getting:
Fatal error: Class 'site\controller\ApplicationHelper' not found in C:\xampp\htdocs\Controller.php on line 17
I'm new to the whole namespaces business but I'm not 100% sure that thats whats behind it. It just seems like its not finding ApplicationHelper.php even though I set the include path to look in that folder. It works if I directly include ApplicationHelper.php in Controller.php. Here is the (relevant) code:
index.php
set_include_path(get_include_path() . PATH_SEPARATOR . 'C:\xampp\htdocs');
require('Controller.php');
\site\controller\Controller::run();
Controller.php
namespace site\controller;
class Controller {
private $applicationHelper;
private function __construct () {}
static function run () {
$instance = new Controller();
$instance->init();
}
function init () {
$applicationHelper = ApplicationHelper::instance();
$applicationHelper->init();
}
}
ApplicationHelper.php
namespace site\controller;
class ApplicationHelper {
private static $instance;
private function __construct () {}
static function instance () {
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
function init() {
}
}
Thanks for the help!