Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I git clone my dependencies?

Suppose I have a project that will be using some of the Google APIs. In order for me to make it easier to work with the API, I want to use the PHP library that Google provides (https://github.com/google/google-api-php-client) Should I just clone it into my current project, and add it to .gitignore? Should I clone it, and start using git modules, or should I just copy the files that I need, and add them to .gitignore?

Another scenario would be when I'm working with libraries that I've created, and that I have locally. Should I clone them into the current project? Should I create symlinks to the files that I need?

Finally, there are some libraries that aside from having the code hosted in github, also provide 'stand alone' files. Think for example of jQuery. In these cases, is it better to just download the file they provide? Or is it better to clone the repository into the current project?

I'm guessing this all has to do with software architecture. Any book recommendations in that topic?

like image 612
Buzu Avatar asked May 23 '26 05:05

Buzu


1 Answers

Package managers were made for this use case.

In PHP, the main package manager is Composer, for which packages can be found on Packagist.org. Per the composer.json file in the Google API PHP client repository, its package is https://packagist.org/packages/google/apiclient.

Composer will install these libraries (along with an autoload file) in a directory called vendor, which you'd add to .gitignore so their contents don't get committed. Composer handles the installation and updates of the dependencies based on your composer.json file.

For JavaScript libraries, http://bower.io/ is frequently used (although many JS libraries are also available via Composer/Packagist).

Both tools allow arbitrary and/or private repositories to be used.

like image 192
ceejayoz Avatar answered May 25 '26 21:05

ceejayoz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!