Having a problem with namespaces and set_include_path() in PHP

steven2000

New Member
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 17I'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\[code\]set_include_path(get_include_path() . PATH_SEPARATOR . 'C:\xampp\htdocs');require('Controller.php');\site\controller\Controller::run();\[/code\]Controller.php\[code\]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(); }}\[/code\]ApplicationHelper.php\[code\]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() { }}\[/code\]Thanks for the help!
 
Back
Top