Should I commit dependencies on Git?

Is it good practice to commit the vendors folder ?

I see many say that it’s bad practice.
But, I think, if I just commit the project without dependencies, what happens if anyone download the .zip or clone my git ?
Will the dependencies also be installed without commit to git?
Is git clone clever enough to know the dependencies by looking at the composer.json and download them automatically ?

And, if you say that I shouldn’t commit the vendors folder,
Should I just use require ‘vendor/autoload.php’ in my files as usual?
Or, what ?

Sorry, I’m very new to Git and Composer

No you shouldn’t, you should list the dependencies in composer.json in the require section. See: https://getcomposer.org/doc/04-schema.md#package-links

When someone installs your package via composer, composer will also download the dependencies.

1 Like

they get installed when you run the dependency builder (npm, composer, bower, grunt, etc.) after cloning the repository.

in your case you would in your CLI move to the project directory where the composer.json file is located and then run composer install.

of course, otherwise you haven’t loaded your dependencies.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.