Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Do you need to add the vendor directory to version control?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you the need to add the vendor directory to version control, I hope you will learn a lot after reading this article, let's discuss it together!

Should I add the vendor directory to version control?

In general, please do not do this. The vendor folder (or other location where your dependent package is installed) should be added to .gitignore / svn:ignore/.

The best way is for all developers to 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 attractive to submit it to the version library in some cases, it can easily lead to the following problems:

● when you update the code, the version control repository code gets bigger and the diff becomes bloated.

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

● git repositories installed by Composer through git in some scenarios will be treated as sub-modules. This is problematic and troublesome because they are not really submodules.

If you really feel you have to do this, you have these options:

1. The version of the dependent package is limited to the released (non-dev) version that has been hit by tag, so that you will only install it through zipped to avoid problems caused by git submodule.

2. Use-prefer-dist or set preferred-install to dist to the config of your project.

3. Remove the .git directory after each dependency installation, and then add them 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 that 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 advantage of this approach is that you don't have to delete these dependencies for the sake of composer update.

After reading this article, I believe you need to add the vendor directory to version control do not have a certain understanding, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report