在作曲家文件中,"引用"参考?

时间:2017-06-20 14:24:25

标签: php drupal composer-php

在我的let cursor = Question.find({ "_id": quesId }, { "pages": 1, "settings.name": 1, "status": 1 }, {limit: 1}); let handle = cursor.observeChanges({ added: (id, fields) => { // look at fields this.added('questions', id, fields); }, changed: (id, fields) => { // look at fields this.changed('questions', id, fields); }, removed: (id) => { this.removed('questions', id); } }); this.ready(); this.onStop(() => { handle.stop(); }); 文件中,我注意到某些软件包的值为composer.lock

reference

有些人只有"dist": { "type": "zip", "url": "https://ftp.drupal.org/files/projects/paragraphs-8.x-1.1.zip", "reference": "8.x-1.1", "shasum": "c678e5704a98c6a0549e415412da081cfeb03a00" },

null

该值是指什么?我认为它指的是提交,但这两个都是"dist": { "type": "zip", "url": "https://ftp.drupal.org/files/projects/redirect-8.x-1.0-alpha5.zip", "reference": null, "shasum": "927aa4c8d8b40b0cd2442bee86f2f386d25e53ca" }, 个包,其中1个有zip而另一个没有。

1 个答案:

答案 0 :(得分:3)

我检查了两个模块的代码并阅读了一些文章。经过一些研究和与JS开发人员的讨论后,我开始了解'参考'在composer文件中表示PHP库标记,分支或zip文件。因此,例如,如果我说我的包引用来自"reference":"master",则每次运行composer update命令时,这将从该存储库中提取代码。定义引用是一种省略将编写器文件添加到库本身的要求的方法。但是如果您的库已经在其自己的目录中使用composer.json文件支持作曲家,那么您将不需要在作曲家文件中定义该包。

现在,让我们来看看这两个模块。首先,在http://cgit.drupalcode.org/paragraphs/tree/?h=8.x-1.x检查Paragraph模块的源代码树,你会注意到那里没有composer.json文件,所以我们必须在composer文件中定义引用参数,告诉应用程序选择正确的源代码文件。但另一方面,如果您在http://cgit.drupalcode.org/redirect/tree/看到重定向模块的代码源树,您将在文件的根目录中找到composer.json。此文件将允许您从应用程序composer.json文件中省略引用参数。

另外,我认为如果我们不定义此参数,则会提取最新内容,并根据上述条件,composer.lock文件会在composer install命令运行时更新。

希望这会清除你的怀疑!