Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should the vendor folder be in source control?

For instance, files like

/vendor/composer/classLoader.php
/vendor/composer/autoload_classmap.php

On a project I'm on these are checked in. I wasn't sure whether that's good practice or not, as I remember reading Laravel recommends /vendor to be in .gitignore.

like image 348
JasonGenX Avatar asked May 20 '15 17:05

JasonGenX


People also ask

Should I Gitignore vendor folder?

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.

What is a vendor folder?

It is a directory found at the root of a Go module that stores a copy of all the code the module depends on. The vendored code is used to compile the final executable when the go build command is run. As you can imagine, at the heart of the “should we commit vendor?” discussion is the problem of repo size.

What is use of vendor folder?

The vendor folder is where you usually (I'm using the word 'usually' because it's not exactly a rule but more of a preference in the coding community with the purpose of having a semantic directory structure) keep third-party resources(icons, images, codes, you name it) as opposed to a lib (library) folder where you or ...

What is vendor folder in PHP?

The vendor is a subfolder in the Laravel root directory. It includes the Composer dependencies in the file autoload. php. Composer is a PHP based tool for dependency management. As a Laravel project works with many libraries, it requires the Composer for dependency management.


2 Answers

No, the vendor directory should be excluded, and never manually touched. A composer update / composer install will generate the class loader when you install your dependencies.

like image 189
ceejayoz Avatar answered Oct 24 '22 06:10

ceejayoz


No, your vendor folder is not part of your source code, and shouldn't be checked in in your git repository.

A good workflow would be :

  • check in your composer.json
  • whenever you want to upgrade your dependencies:
    • run composer update on your local repository
    • check in the changed composer.lock
    • Deploy and run composer install on your production repository

Why should you also check in composer.lock :

Your composer.json defines the acceptable versions of your dependencies that will be used when running composer update.

The problem that comes in when using only composer.json is to have reproducible builds (eg exactly the same versions of your dependencies in all your environments). That is why, when you run composer install, if there is a composer.lock file, composer will instead load the exact same dependencies as the ones written in the composer.lock file. Your composer.lock file is updated whenever you run composer update.

like image 20
edi9999 Avatar answered Oct 24 '22 06:10

edi9999