我有点搞不懂作曲家这个词。在具有存储库的应用程序中使用的锁。

我看到很多人说我们不应该。从存储库锁定。

如果我在开发环境中更新我的库,我将有一个新的作曲家。锁,但我将无法更新到生产,是吗?

它不会在这个文件上产生冲突吗?


当前回答

对于任何在Heroku上的人来说,答案都是明确的“是的,应该承诺”:

如果作曲家。Json在它的require部分指定了任何类型的依赖项,对应的编写器。运行composer update生成的锁也必须提交到存储库,否则推送将被拒绝。

源码:Heroku PHP支持:激活。

其他回答

如果你担心你的代码被破坏,你应该提交编写器。锁定您的版本控制系统,以确保所有项目合作者使用相同版本的代码。如果没有锁定文件,您每次都会得到新的第三方代码。

例外情况是当你使用元应用程序时,需要在安装时更新依赖关系的库(如Zend Framework 2 Skeleton应用程序)。因此,目标是在每次开始开发时获取最新的依赖项。

来源:作曲者:It’s All About the Lock File

请参见:编写器更新和安装之间的区别是什么?

如果你更新了你的库,你也想提交锁文件。它基本上说明您的项目被锁定到您正在使用的库的特定版本。

如果您提交了更改,并且有人提取了您的代码并更新了依赖项,那么锁文件应该是未修改的。如果它被修改了,这意味着您有了某个东西的新版本。

在存储库中使用它可以确保每个开发人员使用相同的版本。

在以两种方式做了几个项目后,我的立场是作曲家。Lock不应该作为项目的一部分提交。

作曲家。Lock是构建元数据,不是项目的一部分。依赖关系的状态应该通过您如何控制它们(手动或作为自动构建过程的一部分)来控制,而不是由上一个开发人员任意更新它们并提交锁文件。

如果你担心在编写器更新之间依赖关系的变化,那么你对自己的版本控制方案缺乏信心。版本(1.0、1.1、1.2等)应该是不可变的,你应该避免在初始特性开发之外使用“dev-”和“x *”通配符。

提交锁文件是依赖项管理系统的回归,因为依赖项版本现在已经回到隐式定义的状态。

此外,你的项目永远不应该在每个环境中重新构建或重新获取其依赖项,尤其是prodd。你的交付品(tar, zip, phar,一个目录等)应该是不可变的,并在环境中进行推广而不需要更改。

You then commit the composer.json to your project and everyone else on your team can run composer install to install your project dependencies. The point of the lock file is to record the exact versions that are installed so they can be re-installed. This means that if you have a version spec of 1.* and your co-worker runs composer update which installs 1.2.4, and then commits the composer.lock file, when you composer install, you will also get 1.2.4, even if 1.3.0 has been released. This ensures everybody working on the project has the same exact version. This means that if anything has been committed since the last time a composer install was done, then, without a lock file, you will get new third-party code being pulled down. Again, this is a problem if you’re concerned about your code breaking. And it’s one of the reasons why it’s important to think about Composer as being centered around the composer.lock file.

来源:作曲者:It’s All About the Lock File。


Commit your application's composer.lock (along with composer.json) into version control. This is important because the install command checks if a lock file is present, and if it is, it downloads the versions specified there (regardless of what composer.json says). This means that anyone who sets up the project will download the exact same version of the dependencies. Your CI server, production machines, other developers in your team, everything and everyone runs on the same dependencies, which mitigates the potential for bugs affecting only some parts of the deployments. Even if you develop alone, in six months when reinstalling the project you can feel confident the dependencies installed are still working even if your dependencies released many new versions since then.

来源:作曲家-基本用法。

对于任何在Heroku上的人来说,答案都是明确的“是的,应该承诺”:

如果作曲家。Json在它的require部分指定了任何类型的依赖项,对应的编写器。运行composer update生成的锁也必须提交到存储库,否则推送将被拒绝。

源码:Heroku PHP支持:激活。