Should composer.lock be committed to version control?

后端 未结 8 2093
攒了一身酷
攒了一身酷 2020-11-28 16:54

I\'m a little confused with composer.lock used in an application with a repository.

I saw many people saying that we should not .gitignore

8条回答
  •  被撕碎了的回忆
    2020-11-28 17:54

    After doing it both ways for a few projects my stance is that composer.lock should not be committed as part of the project.

    composer.lock is build metadata which is not part of the project. The state of dependencies should be controlled through how you're versioning them (either manually or as part of your automated build process) and not arbitrarily by the last developer to update them and commit the lock file.

    If you are concerned about your dependencies changing between composer updates then you have a lack of confidence in your versioning scheme. Versions (1.0, 1.1, 1.2, etc) should be immutable and you should avoid "dev-" and "X.*" wildcards outside of initial feature development.

    Committing the lock file is a regression for your dependency management system as the dependency version has now gone back to being implicitly defined.

    Also, your project should never have to be rebuilt or have its dependencies reacquired in each environment, especially prod. Your deliverable (tar, zip, phar, a directory, etc) should be immutable and promoted through environments without changing.

提交回复
热议问题