是否将作曲家依赖项保存到 GIT
Saving composer dependencies to GIT or not
我想知道是否将由 composer 安装的我的 (ZF2) 依赖项添加到我的 GIT 存储库中。这是我正在与同事讨论如何处理供应商目录。我知道不鼓励将供应商添加到我的 VCS,并且只提交 composer.json 和 composer.lock,但我不完全理解为什么会这样。这意味着我还必须使用 composer 在生产环境中安装依赖项。
生产环境依赖外部资源是不是有点危险?在我看来,将所有依赖项添加到我的 VCS 更安全,在开发环境需要时更新它们,当一切正常时,将更新推送到 VCS。这当然意味着我们需要更多的磁盘空间,但我认为这不应该成为选择不太安全的解决方案的理由。
谁能解释为什么让作曲家长期处理依赖关系更好?
想象一下每次更新依赖项时的差异。
我使用了两种设置。
将所有依赖项保留在 VCS 中会给 git 历史添加一些噪音,并且没有任何优势。
composer install
足够安全,因为它获取准确的版本,并在部署期间执行一次。如果由于任何原因失败,它只是构建失败,并且可能表明存在重大问题,例如有网络。
如果您担心构建期间外部存储库不可用,您可以随时使用 satis 制作所需的第 3 方存储库的 'local' 副本。
在构建过程中添加作曲家挂钩也很常见。没有作曲家,你将需要自己做。
尽管如此,使用 composer 的最大优势是防止 'quick fixes' 在没有适当分叉的情况下在第 3 方库中使用。
官方推荐为commit your .composer.json
and composer.lock
but not your vendor directory:
Should I commit the dependencies in my vendor directory?
The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to .gitignore
/svn:ignore
/etc.
The best practice is to then have all the developers use Composer to install the dependencies. Similarly, the build server, CI, deployment tools etc should be adapted to run Composer as part of their project bootstrapping.
While it can be tempting to commit it in some environment, it leads to a few problems:
- Large VCS repository size and diffs when you update code.
- Duplication of the history of all your dependencies in your own VCS.
- Adding dependencies installed via git to a git repo will show them as submodules. This is problematic because they are not real submodules, and you will run into issues.
如果您仍想提交供应商目录,该页面列出了一些最佳实践。
我想知道是否将由 composer 安装的我的 (ZF2) 依赖项添加到我的 GIT 存储库中。这是我正在与同事讨论如何处理供应商目录。我知道不鼓励将供应商添加到我的 VCS,并且只提交 composer.json 和 composer.lock,但我不完全理解为什么会这样。这意味着我还必须使用 composer 在生产环境中安装依赖项。
生产环境依赖外部资源是不是有点危险?在我看来,将所有依赖项添加到我的 VCS 更安全,在开发环境需要时更新它们,当一切正常时,将更新推送到 VCS。这当然意味着我们需要更多的磁盘空间,但我认为这不应该成为选择不太安全的解决方案的理由。
谁能解释为什么让作曲家长期处理依赖关系更好?
想象一下每次更新依赖项时的差异。
我使用了两种设置。
将所有依赖项保留在 VCS 中会给 git 历史添加一些噪音,并且没有任何优势。
composer install
足够安全,因为它获取准确的版本,并在部署期间执行一次。如果由于任何原因失败,它只是构建失败,并且可能表明存在重大问题,例如有网络。
如果您担心构建期间外部存储库不可用,您可以随时使用 satis 制作所需的第 3 方存储库的 'local' 副本。
在构建过程中添加作曲家挂钩也很常见。没有作曲家,你将需要自己做。
尽管如此,使用 composer 的最大优势是防止 'quick fixes' 在没有适当分叉的情况下在第 3 方库中使用。
官方推荐为commit your .composer.json
and composer.lock
but not your vendor directory:
Should I commit the dependencies in my vendor directory?
The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to
.gitignore
/svn:ignore
/etc.The best practice is to then have all the developers use Composer to install the dependencies. Similarly, the build server, CI, deployment tools etc should be adapted to run Composer as part of their project bootstrapping.
While it can be tempting to commit it in some environment, it leads to a few problems:
- Large VCS repository size and diffs when you update code.
- Duplication of the history of all your dependencies in your own VCS.
- Adding dependencies installed via git to a git repo will show them as submodules. This is problematic because they are not real submodules, and you will run into issues.
如果您仍想提交供应商目录,该页面列出了一些最佳实践。