Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to require two versions of the same package?

Tags:

composer-php

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'" 
       }
   }
like image 893
c33s Avatar asked Nov 01 '22 11:11

c33s


1 Answers

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');
like image 106
Sjaak Wish Avatar answered Dec 24 '22 11:12

Sjaak Wish