I need to install a single composer package into a project - maatwebsite/excel ~2.1.0
. Each time composer updates, it updates all packages in composer.json. How can I avoid updating packages aside from the excel library?
I have tried the following commands but they don't seem to be working:
composer require maatwebsite/excel ~2.1.0
composer require vendor/maatwebsite/excel ~2.1.0
composer update maatwebsite/excel ~2.1.0
composer update vendor/maatwebsite/excel ~2.1.0
I've also tried using the --lock attribute but that's also not working.
Can anybody tell me what I am doing wrong?
if the package is not in the vendor folder.. composer installs it and if the package exists, composer update package to the latest version. Update: require install or update the latest package version. if you want update one package just use update .
composer update will update our dependencies as they are specified in composer. json . Supposing we have actually installed the 2.0. 1 version of the package, running composer update will cause an upgrade of this package (for example to 2.0.
composer. lock records the exact versions that are installed. So that you are in the same versions with your co-workers. composer install. Check for composer.lock file.
To install a composer package with a specific version the docs suggest the use of a colon.
composer require maatwebsite/excel:~2.1.0 --no-update
Also, the composer cli tool composer help require
help reads:
Required package name optionally including a version constraint, e.g. foo/bar or foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"
So to use a space separated version number, you needed the quotation marks surrounding the package/version combination. That is:
composer require "maatwebsite/excel ~2.1.0" --no-update
should work for you too.
To skip updates on any other package, simply add --no-update
to your call. This instructs Composer to only require that new package and not update anything else.
The resulting call could then look like the following:
composer require maatwebsite/excel ~2.1.0 --no-update
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With