PHP on Ubuntu autoload_register and namespacing issue
- by Tian Loon
I have a problem here. I have created the namespace for all classes. previously i was using windows 7 to develop current app, everything is fine. now i just moved to ubuntu, the problem comes.
index.php
spl_autoload_extensions(".php");
/*spl_autoload_register(function ($class) {
require __DIR__ . '/../' . $class . '.php';
});*/
//provided i have tried the above method, which works on windows 7 but not Ubuntu
spl_autoload_register(function ($class) {
require '/../' . $class . '.php';
});
//for your info, i do this
//require "../resources/library/Config.php";
//it works, no error
use resources\library as LIB;
use resources\dal as DAL;
//instantiation
$config = new LIB\Config();
print_r($config->fbKey());
i got this error
PHP Warning: require(../resources\\library\\Config.php): failed to open stream: No such file or directory in /home/user/dir1/dir2/index.php
i cannot find the error. hope you guys can help me with this. any question don hesitate to comment i will edit. thanks in advance.
UPDATE - Extra Info
PHP version 5.4.6
LATEST UPDATE
any idea how to solve this without using str_replace ?