The composer won't use my plug

I am trying to get composer to use my own fork of the library.

Original: https://github.com/KnpLabs/php-github-api My fork: https://github.com/TransitScreen/php-github-api

I was able to install the original along with the composer by simply adding it to the composer .json:

{
    "require": {
        "knplabs/github-api": "~1.4"
    }
}

      

I followed the instructions in the documentation and changed it to this:

{
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/TransitScreen/php-github-api.git"
        }
    ],
    "require": {
        "knplabs/github-api": "dev-master"
    },
    "minimum-stabilitiy": "dev"
}

      

In my forked repository, I have both a branch master

and a dev-master

. I don't understand what is right, so I did both. I have also tried using "type" : "vcs"

and removing .git

from url. None of them work. I run composer update

and then the file composer.lock

is still pointing to the original repo url, not mine. So I never get my changes when I run composer install

.

What am I doing wrong?

PS: I noticed that the library I'm trying to develop has this in the composer.json file:

"extra": {
    "branch-alias": {
        "dev-master": "1.4.x-dev"
    }
}

      

I haven't found any documentation to explain what impact an alias can have. For example, should my forked repository have a branch1.4.x

Update 1 By the way, I know that some of my configurations must be correct because I am on startup composer update

after deleting the cache, there is a moment when I see it reading the composer .json of my (correct) repository. But then the composer .lock still points to the original (incorrect).

Update 2 I also tried to use composer update --prefer-source

but it still doesn't work.

+3


source to share


2 answers


I figured out the problem!

I edited a file composer.json

inside my forked repository ... It looked like this:

{
    "name": "knplabs/github-api",
    "type": "library",
    "description": "GitHub API v3 client",
    "homepage": "https://github.com/TransitScreen/php-github-api",
    "keywords": ["github", "gh", "api", "gist"],
    "license": "MIT",

      

But I changed it to this:



{
    "name": "transitscreen/php-github-api",
    "type": "library",
    "description": "GitHub API v3 client",
    "homepage": "https://github.com/TransitScreen/php-github-api",
    "keywords": ["github", "gh", "api", "gist"],
    "license": "MIT",

      

I thought the name should match the new repository, but I was wrong. When I changed it to its original name, everything works!

Many thanks to @Tomas for helpful troubleshooting tips.

I haven't seen any documentation about this anywhere, so I posted an update for the composer docs: https://github.com/composer/composer/pull/4329

+2


source


First, try renaming your fork to something else (better unique and not available at the beginning) and use that.

Specifically: https://github.com/TransitScreen/gh-api/tree/dev-master



dev-master

=> my-feature

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/TransitScreen/php-github-api"
        }
    ],
    "require": {
        "knplabs/github-api": "newsearch"
    },
    "minimum-stability": "dev"
}

      

+1


source







All Articles