So i have got this small piece of code that auto loads the classes. Everything is going allright until i add namespaces. I get the error that it can't find the Class. But when i remove the namespace it works again. (It also works when i include the wbp.Foo.php directly.)
autoloader.php
<?php
function autoloadLib($className){
$filename = "lib/wbp." . $className . ".php";
if(is_readable($filename)){
require $filename;
}
}
spl_autoload_register("autoloadLib");
index.php
<?php
include "autoloader.php";
use Foobar\Foo;
echo Foo::Bar();
lib/wbp.Foo.php
<?php
namespace Foobar;
class Foo {
public static function Bar(){
return "foobar";
}
}