问题
in my project i need to use two versions of twitter bootstrap (v2.x and v3.x) 2 for the backend and 3 for the frontend. is it somehow possible to require both and tell composer to install them in different directoreies?
something like that:
{
"name": "acme/hello-world",
"require": {
"twitter/bootstrap": "2.3.*",
"twitter/bootstrap": "3.0.* as 'twitter/bootstrap3'"
}
}
回答1:
You can't require two version, your application should only use one version of a package.
回答2:
If you want you can overwrite the namespace inside loader object. Not exactly having two version at the same time. But maybe you want to use an other version somewhere in your scripts.
$reflection = new \ReflectionClass(\Composer\Autoload\ClassLoader::class);
$vendorDir = dirname(dirname($reflection->getFileName()));
$loader->set('Company\\Classname\\', $vendorDir.'/composer/../Other_company/OrOtherClassname/src');
来源:https://stackoverflow.com/questions/19745560/how-to-require-two-versions-of-the-same-package