3

I know it's possible to override a composer dependency using:

"some/module": "1.0.0 as 2.0.0",

But is it possible to entirely remove a dependency that one of my dependencies requires?

The issue is that I am requiring "cwp/cwp-recipe-basic": "1.1.0", which can be found here. That package is simply another list of dependencies, however I do not want one of those dependencies.

Is there any way of telling composer to ignore that one dependency?

E.g.

"cwp/cwp-recipe-basic": "1.1.0",
"silverstripe/fulltextsearch": " as 1.1.0"
scrowler
  • 24,273
  • 9
  • 60
  • 92
Matt L
  • 141
  • 2
  • 9

2 Answers2

1

I guess you can't. But if it is only a list of dependencies why don't you just copy the list except the ones you don't need and paste them into your composer.json?

Another approach could be if it is a long list to fork cwp/cwp-recipe-basic and remove the dependencies you don't need from that list and then require the fork in your project.

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • Then I have to manage all of those dependency versions, instead of getting the latest advised versions by updating just the `cwp-recipe-basic` package. – Matt L Jun 16 '15 at 06:46
  • 2
    The problem is composer was just not made having in mind that someone could create a package that only consists of other dependencies and doesn't have any own code. If someone defines a `package A` to depend on another `package B` what would happen if you remove that `package B` from your project? Right it won't work because `A` needs `B`. Who ever created that package that consists only of dependencies just miss used composer in my eyes. This is no proper way to use composer. – Pᴇʜ Jun 16 '15 at 06:54
  • This is what we (the CWP team) would previously have recommended you do, if you don't need everything in the recipe we provide. Thankfully the recipes are much more isolated in CWP 2.0 now, so you don't need to install everything that the "basic" recipe provides. For the record, this is still what we recommend for CWP 2.0 as well, but again since the recipes are smaller it's less of an issue. The other answer provides a workaround if you don't want to do this. Suggest you mark one of the answers as accepted anyway =) – scrowler Jul 22 '19 at 11:59
1

You can use replace setting in your composer.json:

"replace": {
    "silverstripe/fulltextsearch": "1.1.0"
}

Composer will act as this package is already available and will not install it. Note that you will not able to use it, since it is not actually installed.

rob006
  • 21,383
  • 5
  • 53
  • 74