我有点搞不懂作曲家这个词。在具有存储库的应用程序中使用的锁。
我看到很多人说我们不应该。从存储库锁定。
如果我在开发环境中更新我的库,我将有一个新的作曲家。锁,但我将无法更新到生产,是吗?
它不会在这个文件上产生冲突吗?
我有点搞不懂作曲家这个词。在具有存储库的应用程序中使用的锁。
我看到很多人说我们不应该。从存储库锁定。
如果我在开发环境中更新我的库,我将有一个新的作曲家。锁,但我将无法更新到生产,是吗?
它不会在这个文件上产生冲突吗?
当前回答
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.
来源:作曲家-基本用法。
其他回答
在以两种方式做了几个项目后,我的立场是作曲家。Lock不应该作为项目的一部分提交。
作曲家。Lock是构建元数据,不是项目的一部分。依赖关系的状态应该通过您如何控制它们(手动或作为自动构建过程的一部分)来控制,而不是由上一个开发人员任意更新它们并提交锁文件。
如果你担心在编写器更新之间依赖关系的变化,那么你对自己的版本控制方案缺乏信心。版本(1.0、1.1、1.2等)应该是不可变的,你应该避免在初始特性开发之外使用“dev-”和“x *”通配符。
提交锁文件是依赖项管理系统的回归,因为依赖项版本现在已经回到隐式定义的状态。
此外,你的项目永远不应该在每个环境中重新构建或重新获取其依赖项,尤其是prodd。你的交付品(tar, zip, phar,一个目录等)应该是不可变的,并在环境中进行推广而不需要更改。
如果你更新了你的库,你也想提交锁文件。它基本上说明您的项目被锁定到您正在使用的库的特定版本。
如果您提交了更改,并且有人提取了您的代码并更新了依赖项,那么锁文件应该是未修改的。如果它被修改了,这意味着您有了某个东西的新版本。
在存储库中使用它可以确保每个开发人员使用相同的版本。
不应该直接在生产端更新依赖项。 你应该版本控制你的作曲家。锁文件。 您不应该对实际依赖项进行版本控制。
1. 您不应该直接在Production上更新依赖项,因为您不知道这会如何影响代码的稳定性。新的依赖关系可能会引入错误,它可能会改变代码行为的方式,影响你自己的行为,它可能与其他依赖关系不兼容,等等。你应该在开发环境中完成这些工作,然后进行适当的QA和回归测试等。
2. You should version control your composer.lock file, because this stores information about your dependencies and about the dependencies of your dependencies that will allow you to replicate the current state of the code. This is important, because, all your testing and development has been done against specific code. Not caring about the actual version of the code that you have is similar to uploading code changes to your application and not testing them. If you are upgrading your dependencies versions, this should be a willingly act, and you should take the necessary care to make sure everything still works. Losing one or two hours of up time reverting to a previous release version might cost you a lot of money.
你会看到一个关于不需要作曲家的论点。锁是你可以在你的作曲器中设置你需要的确切版本。Json文件,这样,每次有人运行composer install时,它都会为他们安装相同的代码。这是不对的,因为您的依赖项有它们自己的依赖项,并且它们的配置可能以允许更新到反版本,甚至可能是整个版本的格式指定。
这意味着即使您指定在编写器中使用Laravel 4.1.31。json, Laravel在它的作曲家。2.*. json文件可能需要它自己的依赖,如Symfony event-dispatcher: 有了这种配置,你可能会得到带有Symfony事件调度程序2.4.1的Laravel 4.1.31,而你团队中的其他人可能会得到带有事件调度程序2.6.5的Laravel 4.1.31,这一切都取决于你最后一次运行composer安装是什么时候。
有了作曲家。版本系统中的Lock文件将存储此子依赖项的确切版本,因此,当您和您的队友进行composer安装时(这是您将基于composer. Lock安装依赖项的方式),您将获得相同的版本。
如果你想更新呢?然后在您的开发环境中运行:composer update,这将生成一个新的作曲器。锁文件(如果有新东西),在你测试它,QA测试和回归测试之后。您可以推动它,让其他人下载新的作曲器。锁,既然安全升级。
3. You shouldn't version control your actual dependencies, because it makes no sense. With the composer.lock you can install the exact version of the dependencies and you wouldn't need to commit them. Why would you add to your repo 10000 files of dependencies, when you are not supposed to be updating them. If you require to change one of this, you should fork it and make your changes there. And if you are worried about having to fetch the actual dependencies each time of a build or release, composer has different ways to alleviate this issue, cache, zip files, etc.
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.
来源:作曲家-基本用法。
对于应用程序/项目:当然可以。
composer文档中强调了这一点:
提交应用程序的编写器。锁定(连同composer.json)到版本控制。
就像@meza说的:你应该提交锁文件,这样你和你的合作者就可以在同一组版本上工作,并防止你说“但它在我的电脑上工作”。: -)
对于图书馆:可能不会。
作曲家的文档中提到了这个问题:
注意:对于库,不一定建议提交锁文件(…)
并在这里声明:
对于你的库,你可以提交作曲家。如果你想锁定文件。这可以帮助您的团队始终针对相同的依赖版本进行测试。但是,这个锁文件不会对依赖于它的其他项目产生任何影响。它只对主要项目有影响。
对于图书馆,我同意@Josh Johnson的回答。