ThriftyNick
ThriftyNick

Reputation: 47

How to modify library brought in with Composer without losing changes on update

I'm working with a library which I've installed via Composer. The library needs modifications. What's the best approach to making my modifications without losing them whenever composer update is run? I'm thinking some sort of config setting would be best. I know I could git clone the library and bring it in manually, but then I'd have to do the same for all it's dependencies.

Upvotes: 0

Views: 500

Answers (1)

ivoba
ivoba

Reputation: 5986

Im not sure what you mean by modifications.

If you mean you are the owner of the library and you have ongoing development with possible breaking changes, then you can pin your library to a specific commit in your project:

"me/library": "dev-master#commithash"

If you mean you use an exisiting library you dont own, you should fork the library, make changes in the fork and include the fork in your project.

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/igorw/monolog"
        }
    ],
    "require": {
        "monolog/monolog": "dev-bugfix"
    }
}

Learn here how to do this: https://stackoverflow.com/a/13500676/541949

Upvotes: 1

Related Questions