PHP on Ubuntu autoload_register and namespacing issue

Posted by Tian Loon on Stack Overflow See other posts from Stack Overflow or by Tian Loon
Published on 2012-12-10T16:14:10Z Indexed on 2012/12/10 17:03 UTC
Read the original article Hit count: 248

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 ?

© Stack Overflow or respective owner

Related posts about php

Related posts about ubuntu