Should I add Laravel vendor directory to .gitignore or not? Should I add Laravel vendor directory to .gitignore or not? laravel laravel

Should I add Laravel vendor directory to .gitignore or not?


Composer provides the composer.lock file for this purpose.

Installing a new package, doing a composer update, etc. that causes package changes will write the exact versions of the installed packages to composer.lock. You should include this file in your repository's versioned files.

You can run composer install to automatically install the exact list of package versions from composer.lock. As it's going to be versioned, you can always roll it back to a working version and run composer install again.

Side note: composer dump-autoload shouldn't make any destructive changes in vendor.


vendor directory is in .gitignore by default. And this is a good idea, because composer will install all packages it will find in composer.json for you on any machine at any time. If you have trouble with new version of some package, just change it back in composer.json and run composer update again.

Of course you can remove vendor directory from .gitignore but this will slow down commits and will use much more disk and GitHub/BitBucket space etc.