Pedro
Pedro

Reputation: 838

Problems on installing Laravel Composer dependencies

We are trying to install the package google / recaptcha 1.1 through Composer, in order to install it Composer asks us to install the phpdocumentor package, however when running

# composer require --dev phpdocumentor / phpdocumentor dev-master 

this gives us an error, about which I attach a screen print. enter image description here

Previously to the current state Composer had indicated us a problem with nikic / php-parser package, we found that package listed in the file composer.lock and we removed it, however now composer gives us this error relative to the package symfony / console v4.1.1 that also it is listed in the composer.lock file, we also try to remove this dependency from the composer.lock, but I am not sure that we are doing things right by eliminating these dependencies. Because in addition to deleting one another error is indicated on another package and if we continue like this we would end up eliminating many dependencies. Please help!

Upvotes: 0

Views: 1772

Answers (2)

David Glidard
David Glidard

Reputation: 61

PhpDocumentor you are trying to install requires phpDocumentor/Reflection who requires nikic/php-parser and this version is to high for your other dependencies.

use composer depends nikic/php-parser to understrand what's wrong.

Upvotes: 0

Magus
Magus

Reputation: 2992

don't manually remove stuff from composer.lock

When you require packages without passing a specific version (like dev-master, or ^1) composer will download the latest versions respecting your composer.json and record those versions on composer.lock.

composer.lock is nothing but a byproduct of composer install

If you manually edit composer.lock, you are basically messing up composers internals.

The correct way to remove a package is either running composer remove vendor/package or manually removing it from composer.json and then running composer update

composer.lock is sacred, don't touch it.

Now you've touched it and you want to unscrew yourself, so:

  • remove composer.lock rm composer.lock
  • install your libraries back, and get an untampered composer.lock composer install
  • install your lib composer require --dev phpdocumentor/phpdocumentor dev-master

Same results, different approach:

  • remove composer.lock rm composer.lock
  • update composer.json with your desired libraries (add the phpdocumentor to the dev dependencies section on composer.json)
  • install everything again composer install

Upvotes: 2

Related Questions