How to require two versions of the same package?

╄→гoц情女王★ 提交于 2019-12-23 15:26:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!