0

In my web app I've successfully installed several PHP Github repositories using Composer. The most recent one I installed on my localhost (using php composer.phar update blahblah/blahblah) works great just like all the others. However, when I git pushed my app to my live site, the blahblah/blahblah directory was empty.

I believe this is a Git issue and that my localhost has the blahblah master repo which isn't being shared with my remote, but I'm totally confused as to why this particular repository didn't install like all the other ones. As far as I know I did nothing different with Composer or the Git push/pull I always do.

Thoughts?

tim peterson
  • 23,653
  • 59
  • 177
  • 299
  • Are you checking your `vendor/` directory into Git? Normally I'd recommend tracking your `composer.json` and `composer.lock` files, *ignoring* `vendor/`, and running Composer everywhere you want to have your dependencies, e.g. other development machines, staging server, production, ... – ChrisGPT was on strike Jan 15 '14 at 23:59
  • yeah my `vendor/` directory is being checked in. So what you're saying is I need to 1) delete it from my local, 2) add `vendor/` to my .gitignore 3) check that back in 4) install Composer on my remote 5) run composer update on both local and remote – tim peterson Jan 16 '14 at 00:07
  • You don't *need to* do things the way I would :-). But managing dependencies (installing, upgrading, keeping versions in sync, etc.) is what systems like Composer are designed to do. I'll add an answer with references to the Composer documentation. – ChrisGPT was on strike Jan 16 '14 at 00:11

1 Answers1

3

I'm not sure what's wrong in your case, but for what it's worth the Composer documentation recommends committing the composer.json and composer.lock files and excluding the vendor/ directory from version control.

Then, on other machines where you need to have dependencies (e.g. other development machines, staging and production servers, etc.) you can use composer install or composer update and let the system keep all of your dependencies synchronized for you.

This is one of the major benefits of using a dependency manager: You can define your project's dependencies in a data file, and everybody can use that data file to get the exact same versions of everything installed automatically, without including external libraries in your repository.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257