Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to replace the 3rd party dependency #6705

Closed
kenorb opened this issue Sep 26, 2017 · 8 comments
Closed

How to replace the 3rd party dependency #6705

kenorb opened this issue Sep 26, 2017 · 8 comments
Labels

Comments

@kenorb
Copy link

kenorb commented Sep 26, 2017

My composer.json:

{
  "require-dev": {
    "guzzlehttp/guzzle": "5.3.x-dev as 5.0.0",
    "aeris/guzzle-http-mock": ">=1.1.5"
  }
}

I'm trying to replace requirement for guzzlehttp/guzzle (required by aeris/guzzle-http-mock) and use 5.3.x-dev version instead of 5.0.0.

Also I've tried to use replace section, e.g.

  "replace": {
    "guzzlehttp/guzzle": "5.3.x-dev"
  }

However I've got still the following error:

  Problem 1
    - aeris/guzzle-http-mock 1.1.5 requires guzzlehttp/guzzle ~5.0.0 -> no matching package found.
    - aeris/guzzle-http-mock 1.1.5 requires guzzlehttp/guzzle ~5.0.0 -> no matching package found.
    - Installation request for aeris/guzzle-http-mock 1.1.5 -> satisfiable by aeris/guzzle-http-mock[1.1.5].

Is it possible to achieve the above? To replace the version provided by composer.json hosted on packagist?

@stof
Copy link
Contributor

stof commented Sep 26, 2017

What do you mean by replacing the requirement ?

@stof
Copy link
Contributor

stof commented Sep 26, 2017

btw, if the library says it supports only 5.0.* of guzzle, forcing it to install alongisde 5.3 may create weird issues.

@kenorb
Copy link
Author

kenorb commented Sep 26, 2017

@stof I'd like to install aeris/guzzle-http-mock, however the package has hardcoded:

"guzzlehttp/guzzle": "~5.0.0"

where I'd like to lower the expectation and install ^5.0 or 5.3 (since 5.0.0 doesn't support PHP7, but higher version of that branch fixed already such incompatibility). Since the package is no longer maintained, I need to find some workarounds, ideally without republishing my own fork.

@stof
Copy link
Contributor

stof commented Sep 26, 2017

Well, you should first try to get this change in the library itself. And then, a better solution to solve your issue is to use a forked version of the mock library (adding support for newer Guzzle versions) until the change is merged upstream instead of aliasing guzzle (which may affect other packages, and create weird issues due to lying on the actual version of Guzzle)

See https://getcomposer.org/doc/articles/aliases.md#require-inline-alias for the way to use a fork temporarily.

@kenorb
Copy link
Author

kenorb commented Sep 26, 2017

The package is not maintained anymore and there is another fork at systemhaus/GuzzleHttpMock, but it's supporting Guzzle 6, which my code can't yet (too big change yet), so what you're saying, I should create another fork and publish on packagist with specific dependencies which I want to test. I thought you can use replace or as to replace these dependencies, but it sounds like you cannot.

I've also tested --prefer-source, but it's still reads the dependencies from the packagist, instead of the local source code.

I've also tried to patch composer.json (extra/patches), but again, nothing is downloaded yet since the dependencies are checked at the start (in cache files downloaded from packagist), so nothing is read from actual source code files.

My other idea was to test the new dependencies by editing cache file directly, but it's in a bit different format.

Shouldn't Composer allow to do that in the first place? Is there any planned feature to bypass such limitations? Or can I report one?

@kenorb kenorb changed the title How to use 'replace' or 'as' to replace the 3rd party dependency How to replace the 3rd party dependency Sep 26, 2017
@Seldaek
Copy link
Member

Seldaek commented Nov 30, 2017

The inline alias you used should have worked so not sure what was going on there, but anyway closing as hopefully it's resovled by now. And no publishing forks on packagist is not the way, you should define the repository in your composer.json and not pollute packagist :)

@Seldaek Seldaek closed this as completed Nov 30, 2017
@hayden-t
Copy link

hayden-t commented Jun 30, 2023

I found that just putting the alias require in my composer.json didnt have effect, i had to use require command instead to add it, and then i could require my old package

php composer.phar require "guzzlehttp/guzzle:7.4.5 as 6.3"
php composer.phar require mitchdav/st-george-ipg "1.0.0"

@tiller1010
Copy link

I had a similar issue. The inline alias did work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants