I would like to know it too. + 1
Tutorial: Updating Laravel/laravel
What's the best (git?) way to update my project to be current with laravel/laravel?
This has been posted before but for me, I just look at the changes and change them myself... takes 10 mins (depending on amount). Keep up to date with them and it's fine.
Agreed with bashy. Pretty much manual for me.
Take a look at this thread: https://laracasts.com/discuss/channels/general-discussion/development-in-laravel-5-best-practices
Some of the changes in the laravel/laravel repository are described in the upgrading guide http://laravel.com/docs/4.2/upgrade buy I think that the best way is to just look at files.
Ok, easy enough. Just thought someone somewhere might have automated it.
Well, you could, if you don't change anything in the git :P otherwise, you'll need to compare and update.
*** Updated to include example for cloning the repo without all of the branches and commit history ***
This is what I do....
Clone the Laravel Repo. Specify the branch if you want (i.e. -b develop)
// will contain all branches and commit history
git clone git@github.com:laravel/laravel.git myproject.dev; cd myproject.dev
// will only contain the specified branch one level of history
git clone --depth 1 --branch develop git://github.com/laravel/laravel.git myproject.dev
Run Composer (make sure you're in the project directory).
composer update
Rename my origin in git
git remote rename origin laravel
Add my repo
git remote add origin git@github.com:dberry37388/myproject.git
I go in and make any changes, like removing the composer.lock from .gitignore, adding things like .idea, _ide_helper.php, etc... to my git ignore, then push to my repo again.
Updating Laravel
When I'm working with L5, I generally update a couple times a day. So I'll first do:
git fetch laravel // this grabs the latest from the laravel/laravel repo
Then I'll merge the changes in. Since I'm working with L5 my branch is laravel/develop
git merge laravel/develop
If there are any conflicts, I'll go in and fix them.
Next I'll run a composer update.
composer update
I never ever, ever, ever, ever, ever, ever, ever run composer update on a production app (which you shouldn't be doing with L5 anyway).
Now I have an updated copy of laravel/laravel and fresh composer packages.
Now I can push those changes to my repo if needed.
There could be a better/easier way, if there is please please tell me :)
I never run a composer update on L5 without first updating the laravel/laravel. A lot of issues I see people having is because they failed to do this. Then you end up with old service providers in the configs, missing folders, etc...
I've wrapped this all up in a bash command/alias. Takes less than 10 seconds, not counting the time composer takes.
If playing with L5 has taught me anything at all, I now appreciate the importance of tracking the composer.lock file in my repo even when just "playing around".
In the event that you find that you've accidentally updated resulting in your project breaking, you can check out an older commit and just composer install to get back to a working state by making use of your lock file. This is especially useful when you don't really feel like doing the update song and dance and just want to work on your stuff.
Commit hashes are also present in the lock file for you to keep dependencies at specific commit versions like described here: https://laracasts.com/discuss/channels/general-discussion/l5-recommendable-commit-for-those-who-want-to-exercise
A diff viewing tool as described in the thread that Valorin referenced is also invaluable, my go to application for that being Meld on Linux.
@dberry that seems so much effort just to replace some code in a few files. Would probably do that when there's at least 10 commits so it's worth it.
@bashy That is my start to finish, from setting the project up...
updating is this...
git fetch laravel
git merge laravel/develop
composer update
And I've got a bash alias so for me it is just:
l5update
So literally like 5 seconds, compared to what you are having to do. That's the whole purpose of using git in the first place.
Well, yeah you merge it, still have to get it into your app m87
@bashy, I'm not sure what you mean still have to get it into my app...
The git merge, updates all of the app files and makes all of those changes you are doing manually automatically. There are no manual changes to be made.
The only time I need to touch a file is when there is a conflict, which rarely happens, but when it does, you open the file it tells you, look for the merge areas, fix it and you're done, still under two minutes.
Git is there so you aren't going in and making those manual changes yourself, otherwise you're just as well off using a tarball.
The only real downside of @dberry's approach is that you end up with all of the laravel/laravel commits in your own repo. For small projects, this is fine, but for anything complex, the noise that adds to your commit log can be a problem.
@Valorin, I'm not a git rockstar, but I believe what you can do, is a
git clone --depth 1 --branch develop git://github.com/laravel/laravel.git myproject
This should just get the tip of the specified branch without all of the history and other branches.
Just the tip
@stueynet lol, I wondered how long before someone caught that :)
That won't merge commits though, will it? So you will still have the fun of manually merging everything...
I just maintain a full clean repo in a different directory, which also gives an easy way to check the commit log.
@Valorin... yes, it will merge commits. You basically have two remotes, your origin (this is your repo) and laravel (if you follow the post I had earlier, it's called laravel).
git fetch laravel
git merge laravel/develop
Nial Obrien wrote an article about this awhile back and probably explains it better than I have. I've changed it up a little (using the --depth).
http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
The best way to try it, is to create a new project and give it a shot. I promise you it's way easier than going through and manually changing files. I can't imagine having to do that, it'd make me go nuts.
I like nuts
lol, no comment
Please or to participate in this conversation.