问题
Does composer provide a way to update the package a project was created with? i.e., if I create a new laravel project with the following
composer create-project --prefer-dist laravel/laravel blog
Composer will grab the latest version of the laravel/laravel
package, unarchive it into the blog folder, and then run composer install
from the blog
folder.
What I want/need to know is, does composer provide a way for me to update the laravel/laravel
package that was downloaded to the blog
folder? I know I could run composer update
inside the blog
folder myself, but this will only update things listed in the compser.json
's require
property — it will not update the unarchived laravel/laravel
in blog
(or will it?)
回答1:
As far as I know it's not really possible.
Imagine that you create a new as example Laravel project.
The composer create-project
creates the skeleton with all initial routes in your configuration etc.
From the very very first moment you are starting to change the default routes, removing the default controllers and changing the default views, your project would be out of sync. because meanwhile laravel changes the skeleton to newer versions with some new default routes etc or event changes directory structure.
It would be really hard to merge those changes over your existing application.
A better solution would be to follow the "Upgrade guides" (laravel: https://laravel.com/docs/5.4/upgrade) and then just commit those changes to your own project.
回答2:
If you want to upgrade to a new laravel version, you can always follow the upgrade guide for your specific version:
- Laravel 5.8 to 6.0
- Laravel 5.7 to 5.8
- Laravel 5.6 to 5.7
- Laravel 5.5 to 5.6
If you are more than one version behind, you need to apply the previous upgrade guide. So if you are on 5.6
and want to upgrade to 5.8
, you need to follow the guide for 5.6
to 5.7
and then from 5.7
to 5.8
.
The guides are pretty helpful: they tell you which package must be updated to what version and inform you about deprecated methods which will be removed in the upcoming versions.
Another method which you can use to upgrade to new minor versions is to just look at the differences from one laravel release to the next. That way, you can see what exactly has changed and which files are new (configuration files for example which you can copy and paste into your project as the default composer create-project
command would do).
As for the current version, you can see the commits since last release here: v5.8.30 to 5.8
Directly under the headline for a release, there is a small link labelled "36 commits to 5.8 since this release" which will take you to the link above, just for the latest version.
回答3:
I just needed to do this, and I couldn't find anything simpler than a git clone
and a git pull
(as @Federkun). Maybe an alternative would be to publish a phar
file for the project and download that?
I can see db-ping does this. It's based on joomla/using phar. Here is the main file for building, inspired from joomla's file.
回答4:
That's not the goal of composer, that just manage your packages.
You should see composer create-project
just as a shortcut of git clone
+ composer install
. If you need to deploy your application you've multiple options, from a simple git pull
, to more advanced deployment tools like Capistrano. But composer isn't one of these tools.
来源:https://stackoverflow.com/questions/36392702/composer-updating-a-project-created-with-create-project