Jonathan
Jonathan

Reputation: 307

How do I use my forked version of a repo in Composer?

I was working on a project and ended up having to make a small change to one of the packages I'm using.

That package is: shopifyextras/shopify-php-api-wrapper
Which you can find here: https://github.com/ShopifyExtras/PHP-Shopify-API-Wrapper

My previous composer.json file looked like this:

{
    "require": {
        "monolog/monolog": "1.*",
        "shopifyextras/shopify-php-api-wrapper": "^1.1"
    },
    "autoload": {
        "psr-0": { "MyApp\\": "src/" }
    }
}

After forking the repo and making my changes (I forgot to create a new branch first, but created the branch after committing to master, and pushed it to github - I don't think this should cause any issues given that the branch exists and it does point to the correct head), I then updated my composer.json to use my fork.

After reading the composer docs (https://getcomposer.org/doc/05-repositories.md#vcs) I updated my composer.json to the following:

    {
"minimum-stability": "dev",
"prefer-stable" : true,
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/JonLaliberte/PHP-Shopify-API-Wrapper.git"
        }
    ],
    "require": {
        "monolog/monolog": "1.*",
        "shopifyextras/shopify-php-api-wrapper": "dev-risksbugfix"
    },
    "autoload": {
        "psr-0": { "MyApp\\": "src/" }
    }
}

When I run composer update I receive the following error:

$ composer update --verbose
Loading composer repositories with package information
Updating dependencies (including require-dev)                                   
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package shopifyextras/shopify-php-api-wrapper could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

I have tried:
Using "risksbugfix" instead of "dev-risksbugfix"
Using type "vcs" instead of git"
Removing ".git" from the repo URL
Using "jonlaliberte/shopify-php-api-wrapper" instead of "shopifyextras/shopify-php-api-wrapper"

Any help would be greatly appreciated. Thanks!

Upvotes: 2

Views: 116

Answers (1)

Jens A. Koch
Jens A. Koch

Reputation: 41747

Branch Alias

If you alias a non-comparable version (such as dev-develop) dev- must prefix the branch name.

You branch is a non-comparable version dev-riskbugfix.

You might need to prefix it with dev-: dev-dev-riskbugfix.

Or rename the branch to riskbugfix and get rid of the dev-, then the alias would be dev-riskbugfix.

Upvotes: 3

Related Questions