Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to composer require without actually pulling the package?

Tags:

composer-php

Is there a way to composer require some/thing without actually pulling the package? In my workflow, it would hasten things if I knew a command to just check version requirements and update composer.json without actually doing anything with regard to the vendor directory.

like image 447
Tarek Adam Avatar asked Jan 02 '23 02:01

Tarek Adam


1 Answers

You can use --no-update switch to avoid updating and installing new dependencies - it will only add new dependency to composer.json.

composer require --no-update symfony/symfony

But since require does not check if required package can be installed (it always pick the newest version compatible with your PHP as a constraint, without checking if it will be possible to install), this can leave composer.json in non-installable state. It will also not update composer.lock so composer install may ignore your new dependency. So this is probably a bad idea unless you want to do something with it before you commit new composer.json.

You may try to use --dry-run switch to test what will happen after composer update - you will be able to check if composer.json is installable, but composer.lock still will be out of date.

composer update --dry-run
like image 192
rob006 Avatar answered Jan 13 '23 18:01

rob006