2015-10-16 36 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

感谢您的深入解释。很有帮助! –