Should the vendor directory be added to version control?

藏色散人
Release: 2019-09-20 13:29:34
forward
3201 people have browsed it

Should the vendor directory be added to version control?

composer usage tutorial column provides solutions to various composer problems, such as:

Should I add the vendor directory to version control?

Normally please do not do this, the vendor folder (or other location where your dependent packages are installed) should be added to .gitignore/svn:ignore/......

The best way is to let all developers use the Composer command to install dependencies. Similarly, build servers, deployment tools, etc. need to include running Composer as part of the project boot .

Although it is tempting to submit it to the repository in some cases, it can easily lead to the following problems:

● When you update the code, the version control repository Code gets bigger and diffs get bloated.

● All dependencies of the project will have a copy in your version control.

● In some scenarios, the git repository installed by Composer through git will be treated as a submodule. This is problematic and causes trouble because they are not really submodules.

If you really feel that you must do this, you have these options:

1. The version of the dependent package is limited to the tagged release (non-dev) version. In this case You will only install via zipped, thus avoiding problems with git submodule.

2. Use --prefer-dist or set preferred-install to dist to your project's config.

3. Remove the .git directory after each dependency is installed, and then install them Add to your repository. You can use rm -rf vendor/**/.git (in ZSH) or find vendor/ -type d -name ".git" -exec rm -rf {} \; (in Bash). But this means you need to remove these dependencies the next time you run composer update. /

4. Add a .gitignore rule (/vendor/**/.git) to ignore the .git directory under vendor. The benefit of this approach is that you don't need to remove these dependencies in order to composer update.

The above is the detailed content of Should the vendor directory be added to version control?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template