2015-10-16 40 views
0

遇到了作曲家的問題。我有一個主要項目,正在與一些我建立的小型圖書館合作,我希望更輕鬆地分享我的項目。它們遠不是準備好的,所以我不想將它們添加到packagist中,但是當我需要另一個時,它將會出錯,除非我在我的主composer上也添加了自定義存儲庫。 ,第三要求無法解決packagist庫作曲家自定義存儲庫包無法拉取依賴關係

Your requirements could not be resolved to an installable set of packages. 
Problem 1 
    - ethereal/simpleCache dev-master requires predis/predis ^[email protected] -> no matching package found. 
    - ethereal/simpleCache dev-master requires predis/predis ^[email protected] -> no matching package found. 
    - Installation request for ethereal/simplecache dev-master -> satisfiable by ethereal/simpleCache[dev-master]. 

主要項目composer.json:

{ 
"name": "ethereal/SimpleTable", 
"type": "project", 
"repositories": [ 
    { 
     "type": "vcs", 
     "url": "https://github.com/mathus13/SimpleConfig.git" 
    } 
], 
"require": { 
    "php": ">=5.3.9", 
    "doctrine/dbal": "^[email protected]", 
    "ethereal/SimpleConfig": "dev-master" 
}, 
"require-dev": { 
    "phpunit/phpunit": "~4.8" 
}, 
"autoload": { 
    "psr-4": { 
     "Ethereal\\": "lib" 
    } 
} 
} 

配置庫:在SimpleTable運行作曲家更新時,簡單的緩存將不被包括在內,除非在SimpleTable明確要求。

{ 
"name": "ethereal/SimpleConfig", 
"type": "project", 
"version": "0.0.1", 
"repositories": [ 
    { 
     "type": "vcs", 
     "url": "https://github.com/mathus13/SimpleCache.git" 
    } 
], 
"require": { 
    "php": ">=5.3.9", 
    "ethereal/SimpleCache": "dev-master" 
}, 
"require-dev": { 
    "phpunit/phpunit": "~4.8" 
}, 
"autoload": { 
    "psr-4": { 
     "Ethereal\\": "lib" 
    } 
} 
} 

緩存庫:當在SimpleTable中運行作曲家更新時,predis無法解析。

{ 
"name": "ethereal/simpleCache", 
"type": "project", 
"version": "0.0.1", 
"require": { 
    "predis/predis": "^[email protected]", 
    "php": ">=5.3.9" 
}, 
"require-dev": { 
    "phpunit/phpunit": "~4.8" 
}, 
"autoload": { 
    "psr-4": { 
     "Ethereal\\": "lib" 
    } 
} 
} 

回答

3

ethereal/SimpleTable在開發中的穩定性,這取決於ethereal/SimpleCache在開發穩定,這在開發中的穩定性取決於predis/predis(1.1版尚未發佈)取決於ethereal/SimpleConfig

包含在主包中的包無法定義任何穩定性,唯一的穩定性是主包中的包。這是默認情況下「穩定」。

您可以通過根據「開發高手」爲SimpleConfig」造這條規則的一個例外,但這不是繼承

你有多個解決方案:。

  1. 標籤軟件標籤聲明它比「dev」更穩定,在生產中只使用帶標籤的軟件通常是個不錯的主意
  2. 包含主包中所需的所有包,即使它們未被直接使用也會添加從他們的一般穩定性的例外,並允許作曲家解決任何子依賴資本投資者入境計劃。
  3. 您可以將"minimum-stability":"dev"添加到主要的composer.json,但是這也將允許從分支安裝所有其他軟件包。然而,使用分支是一件非常糟糕的事情,因爲你不能輕易地回到更新之前的版本 - 分支指針只能向前移動。只有標籤會永遠指向同一個軟件。
  4. 添加"prefer-stable":true"是針對問題的某種解決方法,3針對已在穩定版本中提供的軟件包引入該問題。但是,您仍然有問題無法返回到您自己的軟件包的早期版本,因爲您正在使用分支。

如果您仍在開發這些軟件包,根據分支可能看起來有必要。然而,一個好的軟件包可以單獨開發和測試,除了接口定義(將用於模擬一切)外,幾乎沒有任何外部代碼存在,因此通常將所有代碼組合到一起檢查回收分支是編寫不完全分離的代碼的邀請。

如果這些包中的任何一個已經完成(我會說「足夠好」),標記它並依賴於該版本而不是分支。如果您發現錯誤或想要添加新功能,您可以隨時發佈新版本。

+0

感謝您的深入解釋。很有幫助! –