O
O
Oleg Maksimenko2018-10-04 12:42:32
Composer
Oleg Maksimenko, 2018-10-04 12:42:32

How to use your local version of the composer sub-package?

Composer.json has a dependency on the vendor/a package:

{
  "require": {
    "vendor/a": "^0.1.0"
  }
}

The vendor/a package, in turn, has a dependency on the vendor/b package:
{
  "require": {
    "vendor/b": "1.*"
  }
}

Let's say the vendor/b package doesn't work as it should (there are bugs) and we want to fix the vendor/b package. To speed up the process of delivering the corrected vendor/b package, I would like to make the composer use our fork when searching for dependencies (for the time being, until the package developer accepts the vendor/b pull request). At the same time, before starting the edits on the package, I would like to check the work of our edits
Question: is it possible to force the composer to take a local copy of the package so as not to edit the sources during the tests directly in the /vendor/vendor/b folder?
I put a local copy of the package in the .packages/vendor-b folder and I want the composer to take the version from this folder (I made changes beforehand and even committed it locally, let's say to the local-cache branch)
If you add a local repository to composer.json, then the composer does not want to take a new version of the package
"repositories": [
    {
      "type": "path",
      "url": ".packages/vendor-b",
      "options": {
        "symlink": true
      }
    }
],

How to tell him about it?
Variants specified in require cause version conflicts. If you specify a package in replace, the composer removes it altogether

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Medvedev, 2018-10-31
@raidkon

can be done via autoload, an example with the substitution of the dependent package Psr/Log for monolog/monolog

{
    "require": {
        "monolog/monolog": "^1.23"
    },
    "autoload": {
        "psr-4": {"Psr\\Log\\": "./.package/log/Psr/Log"}
    }
}

run the command by itself:
composer dump-autoload

P
Pixilys, 2019-11-13
@Pixilys

Here is some interesting information on the topic.
https://slicks.name/web-dev/lokalnaya-razrabotka-p...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question