3

I want to use a library that defines some extensive dependencies in its composer.json file, even though it only uses one or two small classes of those dependencies.

Is it possible to set up my require in a way that composer thinks I already have those dependencies and lets me use some self-defined minimal mock classes instead?

Example: I want package lib/a which in turn requires lib/b.

Normally I would have something like this in my composer.json:

"require": {
  "lib/a": "^2.2"
}

I thought that maybe 'provide' would fool composer:

"require": {
  "lib/a": "^2.2"
},
"provide": {
  "lib/b": "2.2.0"
}

But it seems to do nothing. Composer still downloads lib/b.

Is there any way to tell composer to ignore a certain dependency?

1 Answer 1

2

Turns out replace does what I want:

"require": {
  "lib/a": "^2.2"
},
"replace": {
  "lib/b": "*"
}

This tells composer that the package at hand replaces any version of lib/b

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.