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 patch a package from another? #13

Closed
boobaa opened this issue May 15, 2018 · 3 comments
Closed

How to patch a package from another? #13

boobaa opened this issue May 15, 2018 · 3 comments
Labels

Comments

@boobaa
Copy link

boobaa commented May 15, 2018

I have a root composer.json which requires two packages, and package B depends on (requires) package A. In order to be able to use package B properly, package A needs to be patched.

How to instruct vaimo/composer-patches from package B's composer.json to patch package A? It would be the best if the root composer.json wouldn't contain these instructions.

@allanpaiste
Copy link
Contributor

allanpaiste commented May 16, 2018

the format for adding patches into a package is exactly the same that you'd use in root composer.json.

So in your case package B would have this:

{
    "extra": {
        "patches": {
            "A": {
                "Compatibility: required change to create magic": "patches/compatibility-with-dependency-a.patch"
            }
        }
    }
}

... where you'd have /patches/compatibility-with-dependency-a.patch and paths in patch are relative to the root of package A.

Note that you can test it out if you have the composer-patches module installed and execute...

composer patch --redo --from-source --filter compatibility-with-dependency-a

The 'filter' part is really optional as you could also try to re-apply everything. the 'from-source' makes the patches scan for patches directly in 'vendor' folder (which allows patches to be pre-tested before [updating/commiting changes to] a given package). The default behaviour is to scan for them in installed.json

@boobaa
Copy link
Author

boobaa commented May 17, 2018

Thanks for your quick answer, works like a charm! Could it also be added to the documentation, please? :)

@allanpaiste
Copy link
Contributor

I'm glad that you got it working :) Added this Q/A as an example to the readme + clarified where the definition format can be used @ 554abba

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

2 participants