public static function registerNamespace($namespace, $path, $classname = null)
    {
        $namespace = trim($namespace, '\\');
        $path = rtrim($path, '/\\');

        $loader = function ($classname, $return_filename = false) use ($namespace, $path) {
            if (class_exists($classname, false) || interface_exists($classname, false)) {
                return true;
            }

            $classname = trim($classname, '\\');

            if ($namespace && stripos($classname, $namespace) !== 0) {
                return false;
            } else {
                $filename = trim(substr($classname, strlen($namespace)), '\\');
            }

            $filename = $path . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $filename) . '.php';

            if ($return_filename) {
                return $filename;
            } else {
                if (!file_exists($filename)) {
                    return false;
                }

                require $filename;

                return class_exists($classname, false) || interface_exists($classname, false);
            }
        };

        if ($classname === null) {
            spl_autoload_register($loader);
        } else {
            return $loader($classname, true);
        }
    }
public static function registerNamespace($namespace, $path, $classname = null)
    {
        $namespace = trim($namespace, '\\');
        $path = rtrim($path, '/\\');

        $loader = function ($classname, $return_filename = false) use ($namespace, $path) {
            if (class_exists($classname, false) || interface_exists($classname, false)) {
                return true;
            }

            $classname = trim($classname, '\\');

            if ($namespace && stripos($classname, $namespace) !== 0) {
                return false;
            } else {
                $filename = trim(substr($classname, strlen($namespace)), '\\');
            }

            $filename = $path . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $filename) . '.php';

            if ($return_filename) {
                return $filename;
            } else {
                if (!file_exists($filename)) {
                    return false;
                }

                require $filename;

                return class_exists($classname, false) || interface_exists($classname, false);
            }
        };

        if ($classname === null) {
            spl_autoload_register($loader);
        } else {
            return $loader($classname, true);
        }
    }
public static function registerNamespace ( $ namespace , $ path , $ classname = null ) { $ namespace = trim ( $ namespace , '\\' ) ; $ path = rtrim ( $ path , '/\\' ) ; $ loader = function ( $ classname , $ return_filename = false ) use ( $ namespace , $ path ) { if ( class_exists ( $ classname , false ) || interface_exists ( $ classname , false ) ) { return true ; } $ classname = trim ( $ classname , '\\' ) ; if ( $ namespace && stripos ( $ classname , $ namespace ) !== 0 ) { return false ; } else { $ filename = trim ( substr ( $ classname , strlen ( $ namespace ) ) , '\\' ) ; } $ filename = $ path . DIRECTORY_SEPARATOR . str_replace ( '\\' , DIRECTORY_SEPARATOR , $ filename ) . '.php' ; if ( $ return_filename ) { return $ filename ; } else { if ( ! file_exists ( $ filename ) ) { return false ; } require $ filename ; return class_exists ( $ classname , false ) || interface_exists ( $ classname , false ) ; } } ; if ( $ classname === null ) { spl_autoload_register ( $ loader ) ; } else { return $ loader ( $ classname , true ) ; } }
class loader.

@param string $namespace
@param string $path
@param string $classname For test

@return void|string
class loader .