Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move some dependecies from require to require-dev with composer?

Some dependencies were mistakenly added to require instead of require-dev. I tried manually changing composer.json and running composer install, but composer.lock wasn't changed. So my guess is, that it ignored changes in composer.json, and just ensured that what's installed reflects what's in composer.lock file. Am I wrong here? If not wrong, how do I do that? I'd like to preserve versions of packages in composer.lock file as they are now as much as possible.

like image 888
x-yuri Avatar asked Oct 29 '16 11:10

x-yuri


People also ask

How do I remove unused dependencies from composer?

Now just open the composer. json file and delete the dependency which you want to remove. Now we just need to run the composer update command once more and it will remove all the phpunit dependencies which we don't want as shown below: Running composer update once again.

What is difference between require and require-Dev in composer?

require: These are must packages for the code to run. It defines the actual dependency as well as package version. require_dev: It defines the packages necessary for developing the project and not needed in production environment. Note: The require and require_dev are important parameters available in composer.

How do I update dependency in composer?

To update dependencies two commands can be used: composer update and composer require . The difference between these two commands is that composer update will try to update a dependency based on the current constraints in composer. json and will only update composer. lock .


1 Answers

I would do:

composer require --dev drupal/devel

or for your example

composer require --dev meenie/javascript-packer: 1.1

which makes composer do all the heavy lifting and moves those dependencies into the require-dev section.

like image 98
Selwyn Polit Avatar answered Sep 20 '22 14:09

Selwyn Polit