Dianbr Posted August 27, 2014 Share Posted August 27, 2014 Hi, I hope someone can help. I am fairly new to php and have the following problem that I cannot get a solution for. We are building a logon system for a website and are receiving the following error. ?>PHP Warning: require_once(classes/Config.php): failed to open stream: No such file or directory in C:\Domains\hellopoker.co.za\wwwroot\test\php\core\init.php on line 22 PHP Fatal error: require_once(): Failed opening required 'classes/Config.php' (include_path='.;C:\php\pear') in C:\Domains\hellopoker.co.za\wwwroot\test\php\core\init.php on line 22 Code for index.php <?phprequire_once 'core/init.php';echo Config::get('mysql/host');?> Code for config.php <?phpclass Config{ public static function get ($path = null){ if ($path){ $config = $GLOBALS['config']; $path = explore('/',$path); foreach($path as $bit){ if(isset($config[$bit])){ echo 'Set'; } } } }}?> Code for init.php <?phpsession_start();$GLOBALS['config'] = array( 'mysql' => array( 'mysql' => 'xxxxxxx', 'username' => 'xxxxxx', 'password' => 'xxxxxxx', 'db' => 'xxxxxxx' ), 'remember' => array( 'cookie_name' => 'hash', 'cookie_expiry' => 604800 ), 'session' => array( 'session_name' => 'user' ));spl_autoload_register(function($class) { require_once 'classes/' . $class . '.php';});?>?> Any help will be greatly be appreciated. Quote Link to comment Share on other sites More sharing options...
IanA Posted August 27, 2014 Share Posted August 27, 2014 (edited) Use relative URLs, depending on where the classes directory lies in your structure, you could do the following:spl_autoload_register(function($class) { require_once ($_SERVER['DOCUMENT_ROOT'] . '/classes/' . $class . '.php'); }); From your error you can see that your autoloader can't find the file to include. Edited August 27, 2014 by IanA Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 27, 2014 Share Posted August 27, 2014 Hard to follow this bunch of code, but the error is pretty self-explanatory. You are trying to find a file that is just where you think it is. The message pinpoints the line with the problem, use the info provided to check your file system to see that the reference is accurate. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.