Change Composer git源的包 [英] Change Composer git source for a package

查看:134
本文介绍了Change Composer git源的包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Composer使用此composer.json插入一个包:

I pull in a package using Composer with this composer.json:

{
    "require": {
        "torophp/torophp": "dev-master",
    },
}


b $ b

当我运行 composer install 时,似乎直接从GitHub中提取这个包。

When I run composer install it seems to pull this package from GitHub directly.

已经创建了一个这个repo在github上的一些小的变化。有没有办法我可以让作曲家在GitHub而不是原来的版本?

I have created a fork of that repo on github with some small changes. Is there a way I can get composer to pull my version on GitHub instead of the original?

推荐答案

如果这是你的< c $ c> composer.json

"require": {
  "torophp/torophp": "dev-master"
}

你的fork代替,只需添加你的仓库到 composer.json 如下:

and you want to change it and use your fork instead, just add your repository into composer.json as follows:

"repositories": [
   {
     "type": "vcs",
     "url": "https://github.com/your-github-username/torophp"
   }
]

重要:不要更改require部分,必须继续使用 torophp / torophp

Important: Do not change the "require" part, it must continue using torophp/torophp!

添加repositories部分后,运行 composer update (或 composer.phar update ),然后作曲家会下载你的音叉(即使它在操作过程中回显安装torophp / torophp)。

After adding the "repositories" part, run a composer update (or composer.phar update) and composer will then download your fork (even though it echoes "installing torophp/torophp" during the operation).

更新(18.09.2014): <@> <@ emesaid / p>

Update (18.09.2014): As mentioned by @efesaid in the comments:


如果你的软件包是在packagist上发布的,你需要添加
code>选项强制从VCS安装。

If your package is published on packagist, you need to add --prefer-source option to force installation from VCS.



:对于那些从HTTP(S)源拉出问题(即你得到 [RuntimeException]无法克隆https://github.com/your-github-username/torophp,无法读取包从尝试更新时),您可以更改 composer.json 以使用git协议。为此,请按如下所示更改 composer.json ,然后再次运行 composer update


Note: For those having issues with pulling from the HTTP(S) source (ie you get [RuntimeException] Failed to clone https://github.com/your-github-username/torophp, could not read packages from it when trying to update), you can change the composer.json to use the git protocol instead. To do so, change the composer.json as follows and run composer update again.

"repositories": [
   {
     "type": "git",
     "url": "git://github.com/your-github-username/torophp.git"
   }
]






现在进入 vendor / torophp / torophp 并运行 git remote -v ,以便双重检查您使用存储库的所需源。


Now go into vendor/torophp/torophp and run git remote -v for a double check that you use the desired source for the repository.

从那里你可以提交更改到你的fork和更新它从原点(<​​code> git pull origin master )。

更新:要在GitHub上使用私有存储库,您必须必须使用git协议,已为git客户端安装了SSH密钥。

From there you can commit the changes to your fork and update it from origin (git pull origin master).


Update: To work with private repositories at GitHub, you must use git protocol and also must have installed SSH keys for a git client.

作曲家参考:从VCS存储库加载数据包

这篇关于Change Composer git源的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆