php - 如何在 Composer 中使用我的存储库的 fork 版本?

标签 php git composer-php

我正在开发一个项目,最终不得不对我正在使用的其中一个包进行一个小更改。

该包是:shopifyextras/shopify-php-api-wrapper
您可以在这里找到:https://github.com/ShopifyExtras/PHP-Shopify-API-Wrapper

我以前的composer.json 文件如下所示:

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

fork 存储库并进行更改后(我忘记先创建一个新分支,但在提交到 master 后创建了该分支,并将其推送到 github - 我认为这不会导致任何问题,因为该分支存在并且它确实指向正确的头),然后我更新了我的composer.json以使用我的fork。

阅读 Composer 文档 ( https://getcomposer.org/doc/05-repositories.md#vcs ) 后,我将 Composer.json 更新为以下内容:

    {
"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/" }
    }
}

当我运行 Composer 更新时,我收到以下错误:

$ 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.

我已经尝试过:
使用“risksbugfix”而不是“dev-risksbugfix”
使用类型“vcs”而不是 git“
从存储库 URL 中删除“.git”
使用“jonlaliberte/shopify-php-api-wrapper”而不是“shopifyextras/shopify-php-api-wrapper”

任何帮助将不胜感激。谢谢!

最佳答案

<强> Branch Alias

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

您的分支是不可比较的版本dev-riskbugfix

您可能需要在其前面添加 dev- 前缀:dev-dev-riskbugfix

或者将分支重命名为 riskbugfix 并去掉 dev-,则别名将为 dev-riskbugfix

关于php - 如何在 Composer 中使用我的存储库的 fork 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35716021/

相关文章:

php - Composer 更新显示 mmap() 失败 : [12] Cannot allocate memory

php - 在共享主机上安装 Composer

php - laravel 在验证 FormRequest 后返回错误而不是重定向的 json

PHP - 为什么比较两个完整的长(相同)字符串比比较每个字符串的第一个字符要快得多?

Git Hook : once a branch is merged into master - update JIRA status

node.js - Heroku:应用程序 fork 后出现 Git 错误

php - Composer /PHP : How to check if composer package is installed?

php - 使用php从mysql数据中过滤多个产品

php - 简单的 Select Sql 语句返回空

Git 子模块更新给出 "error: invalid key (newline)"