如何使用反向依赖关系进行分叉?

时间:2016-11-29 09:41:05

标签: php dependencies composer-php git-fork

我分叉laravel/framework并希望使用克隆的testing-encoding分支:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/x-yuri/framework"
        }
    ],
    "require": {
        "laravel/framework": "dev-testing-encoding"
    }
}

但当我composer require modelizer/selenium时,它会说:

Using version ^1.1 for modelizer/selenium
./composer.json has been updated
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
    - laravel/framework 5.4.x-dev requires symfony/console 3.2.* -> satisfiable by symfony/console[3.2.x-dev, v3.2.0-BETA1, v3.2.0-RC1, v3.2.0-RC2] but these conflict with your requirements or minimum-stability.
    - laravel/framework 5.4.x-dev requires symfony/console 3.2.* -> satisfiable by symfony/console[3.2.x-dev, v3.2.0-BE
TA1, v3.2.0-RC1, v3.2.0-RC2] but these conflict with your requirements or minimum-stability.
    - Installation request for modelizer/selenium ^1.1 -> satisfiable by modelizer/selenium[v1.1.0].
    - Conclusion: remove laravel/framework dev-testing-encoding
    - Conclusion: don't install laravel/framework dev-testing-encoding
    - modelizer/selenium v1.1.0 requires laravel/framework ^5.1 -> satisfiable by laravel/framework[5.4.x-dev, 5.1.x-de
v, 5.2.x-dev, 5.3.x-dev].
    - Can only install one of: laravel/framework[5.1.x-dev, dev-testing-encoding].
    - Can only install one of: laravel/framework[5.2.x-dev, dev-testing-encoding].
    - Can only install one of: laravel/framework[5.3.x-dev, dev-testing-encoding].
    - Can only install one of: laravel/framework[dev-testing-encoding, 5.1.x-dev].
    - Can only install one of: laravel/framework[dev-testing-encoding, 5.2.x-dev].
    - Can only install one of: laravel/framework[dev-testing-encoding, 5.3.x-dev].
    - Installation request for laravel/framework dev-testing-encoding -> satisfiable by laravel/framework[dev-testing-e
ncoding].


Installation failed, reverting ./composer.json to its original content.

我尝试使用minimum-stability和稳定性标记进行试验。无济于事。我能想到的最好的就是fork modelizer/selenium,并在那里硬编码laravel我需要的分支:

diff --git a/composer.json b/composer.json
index 9036e47..65facf0 100644
--- a/composer.json
+++ b/composer.json
@@ -12,8 +12,14 @@
             "email": "john.hoopes@madisoncreativeweb.com"
         }
     ],
+    "repositories": [
+        {
+            "type": "vcs",
+            "url": "https://github.com/x-yuri/framework"
+        }
+    ],
     "require": {
-        "laravel/framework": "^5.1",
+        "laravel/framework": "dev-testing-encoding",
         "symfony/process": ">=2.7",
         "phpunit/phpunit-selenium": ">=1.2",
         "guzzlehttp/guzzle": "^6.2"

将回购添加到根composer.json

{
    "type": "vcs",
    "url": "https://github.com/x-yuri/Selenium"
}

然后执行:composer require modelizer/selenium=dev-laravel-testing-encoding。这也意味着,我也必须分叉laravel/socialite,尽管它不需要直接laravel/framework。它可以比这简单吗?

1 个答案:

答案 0 :(得分:1)

GitHub上的那些人see我就是这个人。您可以{{3}},modelizer/selenium需要laravel/framework=^5.1。我们想要laravel/framework=dev-testing-encodingcomposer不知道如何比较这两个版本,除非我们告诉它:

"require": {
    "laravel/framework": "dev-testing-encoding as 5.1.0"
}

通过这种方式,我们向composer传达dev-testing-encoding可以视为版本5.1.0。换句话说,我们将dev-testing-encoding设为5.1.0。因此,它满足modelizer/selenium的依赖性,并要求包成功。