Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ibanks's avatar

Ignoring the Vendor Folder In GIT

Hello guys.

I'm trying to understand the practice of ignoring the vendor folder in a GIT repo. It's not making sense to me because if I need to deploy my project, I would then need to run composer dump-autoload on the server the project is deployed too each time there is a new class, service provider..etc.

0 likes
5 replies
ibanks's avatar

Okay so what if the "vendor/composer" is the only directory in the vendor folder that isn't ignored and placed under version control? I'm asking this because I'm trying to see if it's absolutely necessary to have a hook via shell script to run composer dump-autoload whenever we deploy the repo to a server.

MikeHopley's avatar

If you're using git for deployment, you would normally have a post-receive hook. This runs composer install first, followed by php artisan optimize.

1 like
ibanks's avatar
ibanks
OP
Best Answer
Level 1

@MikeHopley

I just read about your suggestion on composer install. This is definitely correct as what I need to do is place composer.lock under version control as well as composer.json. Once I do that, composer install command will install the exact dependencies for my project after the post-receive hook is executed. Thanks for that.

Please or to participate in this conversation.