looks like symfony2 classloader does not allow different paths for namespaces, anyone has any idea?(except changing the classloader).
$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespaces(
array(
'Symfony\\Component' => \realpath('/myapp/path' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'Symfony2Components')
)
);
$loader->register(true);
// in other file
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals(); // <-- resolves to : '/myapp/path/vendor/Symfony2Components/Symfony/Component/HttpFoundation/Request.php'
// expected '/myapp/path/vendor/Symfony2Components/HttpFoundation/Request.php'
It’s not a bug. Symfony2 ClassLoader just conforms to the PSR-0:
You just define the root path, but all the namespace parts will still be used in the path.