Our PHP application has a Packagist dependency aaa/foo
defined in our composer.json file.
This package has a dependency of a deleted Packagist package, let’s call it: bbb/bar
.
This is breaking our composer install
.
I have a copy of the deleted package (bbb/bar
) from an old install. What is the easiest way to resolve this given aaa/foo
has not been updated?
I’m hoping there’s a way I can copy the source of the missing package to a directory in a lib
directory of the codebase and map it in composer.json
… but I don’t think aaa/foo
would recognize that override.
3
Answers
If you have the deleted
bbb/bar
package, place it in a local folder.In the composer.json file of the downloaded and locally placed
bbb/bar
package, set the required version number:Then, in the project where you are using
aaa/foo
, reference your local package so that it can be installed as a "dependency":I would try the following:
bbb/bar
into any locallib
folder in your applicationcomposer.json
such that the code from the package is found when it needs to be importedbbb/bar
to thereplace
section of yourcomposer.json
It might be neccessary to call
composer update bbb/bar
once such that the package is removed from the lock fileThe manual for
composer.json
has a description of the "replace" section:You can use this to replace a third-party package in two different ways:
acme/frobulator
, you might createcoder1/frobulator
and list"replace": {"acme/frobulator": "self.version"}
.composer.json
."coder1/frobulator"
in your normal"require"
section, and Composer would know it meets the requirements of other packages which ask for"acme/frobulator"
at the same version"replace": {"acme/frobulator": "1.42.0"}
"psr-4": {"AcmeFrobulator": "third-party/acme/frobulator/src"}
Import Note: You should make an effort to check that you have the legal ability to use or host the missing package. It’s possible that the licence it was distributed under limits how you can use or distribute your fork.
It’s also possible that it was removed because it was in breach of somebody else’s copyright or other rights; if so, the licence it was distributed under is invalid (put crudely: if they stole it, it was never up to them whether you could use it).