Home Development Tools composer Does the content downloaded by composer need to be submitted to git?

Does the content downloaded by composer need to be submitted to git?

Jun 08, 2021 pm 03:46 PM
composer

The following tutorial column of composer will introduce to you the question of whether the content downloaded by composer needs to be submitted to git. I hope it will be helpful to friends who need it!

Specific question:

I would like to ask all the students who use Composer, will you submit the content of the files downloaded through Composer to Git?
I saw the article Should I Commit the dependencies in my vendor directory on the official Faq. Some people suggested not to submit it to Git. So how should I deal with the problem of re-composer install when switching branches? If the vendor is submitted to the repository, how should the .git folder in the package be handled?

*Correction composer update should be composer install

Solution:

In fact, whether it is branch development or deployment to the production environment , no matter how you write the wildcard rules for the version number in composer.json, what we are most concerned about is always the most fundamental content: At the time of development, what is the specific version number of all the dependent libraries we used?

This content is supported by the composer.lock file. By maintaining lock files, composer itself records the specific versions of all dependent libraries in the project after any changes are made to the dependent libraries. Please read the documentation about this file (https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file).

You should always submit the composer.lock file to the repository, and after switching branches or deploying, use composer install to install the specific dependency versions specified in the lock file.

In this sense, it is correct whether you submit the vendor directory to the main repository. It is a trade-off choice whether to submit or not:

If submitted:

Advantages: "Pull and use" convenience.

Disadvantages: Duplication of information. Because of the specific version you developed at the time, the lock file has been recorded. In other words, the vendor folder expresses the same thing.

Disadvantage: Risk of introducing inconsistency. Because although Composer ensures that the lock file is consistent with the vendor directory, submitting it to the git repository is a manual act after all. You can't guarantee that you won't fall behind one of the two.

If you do not submit, the advantages and disadvantages will be reversed. Not to be repeated again.

My thoughts are: I suggest you stick to the idea of ​​"correctness over ease of use". My suggestion is not to submit to the vendor, but just use the lock file to maintain the version of the dependent library at the time of development.

If you submit, please be sure to follow the following two guidelines:

(1) Be sure to ensure that the submission of the two files vendor and composer.lock is synchronized. If one is mentioned, the other must be mentioned.
Any development, if only one of the commits is submitted, must be held accountable.
The reason for this is: Although we submit to the vendor to ensure that it is available immediately after pulling it, git has a partial checkout function - for a Composer project, I have the right to follow the convention of the Composer project and not check out vendor directory, but pull down the actual code and then do a composer install. You can't say I'm wrong.
(If anyone says this is wrong, I support you to expose your unscrupulous company and technical director on SF and Zhihu every minute)

(2) Be sure to follow Composer’s instructions for submitting the vendor folder Suggestion (https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md), ignore all .git directories of sub-library, and only submit the ones in vendor Code of practice.
Believe me, the actual code in the vendor and the management files of the git library itself under vendor/**/.git are definitely related to the above-water part and the underwater part of the iceberg. If you don't ignore it, people will die. It's not an exaggeration.

It must also be pointed out that during branch development, even if you do not synchronize the vendor through the repository, but only synchronize composer.lock, it will not cause a waste of time.

When switching between two branches, it is nothing more than switching back and forth between two specific versions. Composer itself caches all downloaded libraries. The composer install after each branch pull will definitely hit all caches, without repeatedly consuming download time.

The above is the detailed content of Does the content downloaded by composer need to be submitted to git?. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP calls AI intelligent voice assistant PHP voice interaction system construction PHP calls AI intelligent voice assistant PHP voice interaction system construction Jul 25, 2025 pm 08:45 PM

User voice input is captured and sent to the PHP backend through the MediaRecorder API of the front-end JavaScript; 2. PHP saves the audio as a temporary file and calls STTAPI (such as Google or Baidu voice recognition) to convert it into text; 3. PHP sends the text to an AI service (such as OpenAIGPT) to obtain intelligent reply; 4. PHP then calls TTSAPI (such as Baidu or Google voice synthesis) to convert the reply to a voice file; 5. PHP streams the voice file back to the front-end to play, completing interaction. The entire process is dominated by PHP to ensure seamless connection between all links.

What are some best practices for using Composer in production environments? What are some best practices for using Composer in production environments? Jul 08, 2025 am 01:00 AM

When using Composer in a production environment, you need to pay attention to safety, stability and performance. 1. Use composerinstall-no-dev to reduce unnecessary development dependencies and reduce online environment risks; 2. Always submit and rely on composer.lock files to ensure version consistency, and avoid using updates during deployment; 3. Optional configuration platform-check=false ignores platform differences warnings, which is suitable for building packaging scenarios; 4. Enable APCU to accelerate automatic loading to improve performance, especially suitable for high concurrency services, while paying attention to namespace uniqueness to avoid cache conflicts.

How to use PHP to combine AI to generate image. PHP automatically generates art works How to use PHP to combine AI to generate image. PHP automatically generates art works Jul 25, 2025 pm 07:21 PM

PHP does not directly perform AI image processing, but integrates through APIs, because it is good at web development rather than computing-intensive tasks. API integration can achieve professional division of labor, reduce costs, and improve efficiency; 2. Integrating key technologies include using Guzzle or cURL to send HTTP requests, JSON data encoding and decoding, API key security authentication, asynchronous queue processing time-consuming tasks, robust error handling and retry mechanism, image storage and display; 3. Common challenges include API cost out of control, uncontrollable generation results, poor user experience, security risks and difficult data management. The response strategies are setting user quotas and caches, providing propt guidance and multi-picture selection, asynchronous notifications and progress prompts, key environment variable storage and content audit, and cloud storage.

PHP integrated AI intelligent picture recognition PHP visual content automatic labeling PHP integrated AI intelligent picture recognition PHP visual content automatic labeling Jul 25, 2025 pm 05:42 PM

The core idea of integrating AI visual understanding capabilities into PHP applications is to use the third-party AI visual service API, which is responsible for uploading images, sending requests, receiving and parsing JSON results, and storing tags into the database; 2. Automatic image tagging can significantly improve efficiency, enhance content searchability, optimize management and recommendation, and change visual content from "dead data" to "live data"; 3. Selecting AI services requires comprehensive judgments based on functional matching, accuracy, cost, ease of use, regional delay and data compliance, and it is recommended to start from general services such as Google CloudVision; 4. Common challenges include network timeout, key security, error processing, image format limitation, cost control, asynchronous processing requirements and AI recognition accuracy issues.

How do I add a custom repository to my Composer configuration? How do I add a custom repository to my Composer configuration? Jul 06, 2025 am 12:26 AM

To add a custom repository to the Composer configuration, edit the composer.json file in the project and specify the repository information under the "repositories" key. The specific steps are as follows: 1. Determine the repository type, such as VCS (Git, SVN, etc.), Composer, PEAR or Package; 2. Add the "repositories" block in composer.json and fill in the repository type and URL. For example, when using a VCS-type Git repository, the format is {"type":"vcs","url":"https

How do I install a Composer plugin? How do I install a Composer plugin? Jul 09, 2025 am 12:01 AM

To install the Composer plug-in, please first confirm that Composer is installed and the composer.json file exists, and then follow the following steps: 1. Make sure that Composer has been installed and created composer.json; 2. Search and copy the required plug-in name on Packagist; 3. Use the composerrequirequire command to install the plug-in, such as composerrequiredealerdirect/phpcodesniffer-composer-installer; 4. Verify whether the plug-in is effective and check compatibility and configuration. Follow these steps to correctly install the Composer plug-in.

How do I check if Composer is installed correctly? How do I check if Composer is installed correctly? Jul 07, 2025 am 12:12 AM

To check whether Composer is installed correctly, first run the composer--version command to view the version information. If the version number is displayed, it means that it is installed. Secondly, use the composerdiagnose command to detect configuration problems and ensure that the environment variables and permissions are normal. Finally, try to verify the functional integrity through the composerrequiremonolog/monolog installation package. If the vendor directory is successfully created and the dependency is downloaded, it means that Composer is fully available. If the above steps fail, you may need to check whether PHP has been installed globally or adjusted system path settings.

How to make PHP container support automatic construction? Continuously integrated CI configuration method of PHP environment How to make PHP container support automatic construction? Continuously integrated CI configuration method of PHP environment Jul 25, 2025 pm 08:54 PM

To enable PHP containers to support automatic construction, the core lies in configuring the continuous integration (CI) process. 1. Use Dockerfile to define the PHP environment, including basic image, extension installation, dependency management and permission settings; 2. Configure CI/CD tools such as GitLabCI, and define the build, test and deployment stages through the .gitlab-ci.yml file to achieve automatic construction, testing and deployment; 3. Integrate test frameworks such as PHPUnit to ensure that tests are automatically run after code changes; 4. Use automated deployment strategies such as Kubernetes to define deployment configuration through the deployment.yaml file; 5. Optimize Dockerfile and adopt multi-stage construction

See all articles