2
votes

As I understand it, with any project that uses Composer, the correct way to deploy to production server is by not tracking the vendor folder in Git, but instead running Composer on the production server and letting it fetch all the necessary packages and populate the vendor folder for you. Firstly, have I got that bit right? (This may sound like a stupid question but nobody has ever explicitly stated this to me)

Secondly, my production server is a cheap shared hosting environment, not a shiny expensive AWS or Digital Ocean box, so I cannot install Composer in the production environment. As much as I'd like to do things the ideal way, I can't. So is the next best option to track the vendor folder in Git and deploy the packages that way. Then in the future, if I upgrade to a hosting package with more flexibility, I can stop tracking the vendor folder and start doing things the ideal way?

2
Responses : Yes. Yes. - Veve

2 Answers

3
votes

Your understanding of how the vendor map is supposed to be used is correct.

For your second question, I would only choose your solution as a last resort; it's far from ideal. Your repository will need constantly updating with third-party changes.

In you case I would prefer to:

  1. Install php, composer and git locally. This is possible in Windows, OSX and Linux.
  2. Mirror your site locally, and perform the composer updates there.
  3. Copy updates via FTP (or whatever you use) to your production site.

This keeps your repository compact and managable. You only ever need to commit your own changes to the repository.

If, at any point in the future, you can run git on the server, you can keep using the repository without having to clear out the entire vendor map.

0
votes

Yes, that's how people usually use composer.

If you have shell access on this server, you can easily use composer. Just include composer.phar in repo, then you can run php composer.phar install on your shared server.

You can get latest composer from their website (https://getcomposer.org/download/).

If you don't have shell access, then you can put vendor in git, but I would rather copy vendor manually via FTP, than store this in git. I assume, that since you use git on your server side, that you have shell access, and that's not the case ;)