phpcomposer-php

How do I resolve deleted Packagist package that was a dependency of a dependency?


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.


Solution

  • 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:

    {
        "name": "bbb/bar",
        "description": "...",
        "type": "library",
        "version": "1.2.3", // Here
    }
    

    Then, in the project where you are using aaa/foo, reference your local package so that it can be installed as a "dependency":

    "repositories": [
        {
            "type": "path",
            "url": "./lib/bbb-bar"
        }
    ],
    "require": {
        "aaa/foo": "^1.0",
        "bbb/bar": "1.2.3"
    }