Reputation: 951
I have my local git repo on my machine with composer and all of that installed. I then have a remote server for hosting my website where I have a bare repo that has a post-receive hook that does a checkout to the var/www/ file (GIT_WORK_TREE=/var/www/ git checkout -f).
Now, when I was using codeigniter or other non-composer based websites, it was as simple as committing changes and pushing it to the server. As this is my first experience with composer, I'm having a few headaches.
How do I go about setting up laravel 4 on the remote server so I can push changes to it? Do I need to install composer? If I update my composer.json required, do I need to do "composer dump-autoload" on the server as well or "composer update"? Basically, is there a quick rundown or tutorial on how to manage the workflow?
I'd insanely love it if I had the simple "git commit && push" and it did everything for me, including all the composer stuff, on the server.
Thanks!
Upvotes: 3
Views: 2448
Reputation: 12293
How you can accomplish this depends on a bit on your hosting. You need a certain level of access to auto-deploy from Git. Some companies, such as Heroku and FortRabbit, have this functionality built in. If your hosting doesn't, here's a few notes on how you might accomplish that:
This is in the .gitignore
file as the creators of Laravel don't want it in the repository. You should have it in your version control, however, as it's what your production server should read when updating dependencies on your production server.
When you update your server from git, you should have the composer.lock
file updated in there as well.
The steps for this are usually:
These are outlined in detail on this article about deploying from github using webhooks and nodejs
After you get the latest code from Github, you may have updated dependencies as defined in your composer.json
file (and set in your composer.lock
file). Here's a little explanation on why you use composer.lock
in production in conjunction with the composer install
command. (composer update
is good for development, composer install
for production).
You can run (probably from the same script which tells git to pull the latest in production) to run composer install
after the latest changes from Git are pulled in.
Upvotes: 3