Upgrade one version at the time. Make sure it's working each time. It is only two versions, so it shouldn't be that bad
Steps to upgrade laravel from 5.8 to 7.0
I'm currently using laravel 5.8 for my websites. but the support for 5.8 has been stopped. So I want to update my website to 7.0. I saw may breaking changes mentioned in the upgrade guide. I'm a bit confused about updating 5.8 directly to 7.0.
So what are the steps to be followed to update to 7.0
The easiest way is first upgrading to Laravel 6. If you have everything running you can upgrade to Laravel 7. That is the easiest way. You can directly update, but you will probably have more troubles than upgrading for each version.
There is also a tool that can help you upgrade to Laravel 7 right away: https://laravelshift.com/
I just answered this, the above and:
https://laracasts.com/discuss/channels/laravel/composer-require-laravelui-error
Update laravel first then the framework.
see https://laracasts.com/discuss/channels/guides/update-upgrade-laravel-then-framework
and https://laracasts.com/discuss/channels/laravel/updated-from-6-to-70
It doesn't matter what version, even 5.7 to 7 if you update (upgrade) laravel first.
You do not need a shift tool, just a good compare tool, I use winmerge.
17 minutes.
Before you start, check all the packages you need have been updated for Laravel 7.x
Check composer.json, and through packagist check the compatibility
Every time there's an upgrade there's folks who do not follow the upgrade guide and do not check their packages.
They forget to update laravel first and their composer.
My update took me 17 minutes with no problems.
Folks, it should really go without saying to make sure your packages are also updated, meaning the ones you added.
And of course you should make sure laravel, not the framework, but laravel is updated prior to updating the framework or upgrading the framework whichever is the case.
If a little thought is put into this it's an easy 15 to 20 minute thing.
This is a quote from the laravel 7 upgrade guide:
quote
Finally, examine any other third-party packages consumed by your application and verify you are using the proper version for Laravel 7 support.
unquote
Reference: https://laravel.com/docs/7.x/upgrade
Thanks. I NEVER upgrade Laravel/Laravel
Just bump the framework number
AFTER first checking all package version compatibility
That works in many cases, but just example, look at just one file web.php
6.x
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
7.0
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
A whole new line added:
use Illuminate\Support\Facades\Route;
By using a compare tool, you ensure all files are updated. A file such as this, that line would need a copy and paste over since there are existing routes.
All I know, I have never had problems updating / upgrading except the new ui in ver 6 at first I had to figure out.
But I suspect there will be 20 to 70 more post come up with problems updating / upgrading because so many will not (refuse to) read the upgrade guide.
The only reason I use a compare tool is not to miss something, that way a version 6.* (laravel not framework) is fully upgraded to 7.*. Composer takes care of the framework.
But yes every file isn't necessary, I know that. But I like all files brought up to date, just me.
Hi @jlrdw
how do you check the unique packages our apps have against the Laravel ^7.0 requirements?
I went through your guide, this https://www.youtube.com/watch?v=-5QcxlpyA7Y and have spent just shy of 8 hours today upgrading from 6-7.
Had to reset to the last git commit, as I'd sabotaged the vendor directory.
Most of errors today were like this:
- Can only install one of: symfony/process[5.0.x-dev, 2.0.5].
The packages that you've added that's not part of laravel you have to check them yourself to see if they meet requirements, but Taylor does mention that in the upgrade guide.
Bottom line if some packages aren't ready yet don't upgrade yet give them a month to catch up.
Not all packages out there will immediately be laravel 7.0 ready.
Some may even take longer.
geez, @jlrdw I didn't know that.
this nesbot/carbon is driving me mad. I think I'll take it easy on laravel 7 and wait a bit.
It sure would be nice to run a command that says
if (you want to upgrade to laravel 7)
update: such and such
then (upgrade laravel/framework to ^7.0)
Seems like there'd be something for that??
@trevorpan carbon is already there, carbon is pulled in with the framework, not laravel.
You may want to use https://laravelshift.com/
But if done right, it not hard to upgrade.
Take time and view the various composer.json files on github.
@jlrdw I've read through the posts you linked in your comment. I understand what you mean by "Update laravel first then the framework", but I don't see in any of the posts how to do that. I've tried
laravel upgrade
composer upgrade laravel/laravel
composer update laravel/laravel
All of these result in errors, maybe I'm just missing it?
@ignium laravel has to be manually updated. Just follow that upgrade guide in the documentation.
It's just my preference to update all of laravel first, though not required, but Taylor does mention it doesn't hurt if you want to stay completely updated and upgraded.
I myself use a compare tool where I compare a version 6 with a version 7 for example, and make the changes in development as needed.
but that's my preference the way I like doing it.
But if you read the upgrade guide GitHub has a list of changes and what was changed, trust me read the upgrade guide thoroughly.
@jlrdw Is there a page other than Upgrade Guide that I'm missing. I get that you're saying that Laravel and the framework are separate, but I don't see anywhere on this page that says to upgrade Laravel. The first instructions are:
Update your laravel/framework dependency to ^7.0 in your composer.json file. In addition, update your nunomaduro/collision dependency to ^4.1, phpunit/phpunit dependency to ^8.5, laravel/tinker dependency to ^2.0, and facade/ignition to ^2.0.
and then it goes on to discuss 1st-party and 3rd-party packages.
I'm just confused as to "what I need to type where" in order to upgrade the Laravel package itself or does this require a fresh install and copying files into the new project?
ETA: Ah. I see what you're saying, by manually edit you mean, update each changed file individually? I can see why you might want to do this to have each file up-to-date, but is it necessary for an upgrade?
Update your laravel/framework dependency to ^7.0 in your composer.json file.
Means the laravel composer.json file is to be updated so it will pull in version 7.0 of the framework.
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0", ///// HERE
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
Any third party packages, you have to manually place in there also. The upgrade guide covers this.
Another example:
https://laravel.com/docs/7.x/upgrade#symfony-5-related-upgrades
You manually change these two line:
public function report(Throwable $exception);
public function render($request, Throwable $exception);
He tells you the file to change: App\Exceptions\Handler
So just follow the guide.
I've done that, but I thought that was only updating the framework and not the laravel app itself. I think the problems I'm experiencing might go back to my 5.8 -> 6.0 upgrade, probably a topic for a different post (after some additional troubleshooting).
I'm picking up what you're dropping now. I was thinking there was another command that need to be ran, but you were referring to going through and making the updates to the files as listed in the update guide.
Thanks for clearing that up!
You have to do a 5.8 to 6 then 6 to 7.
After completely updating "laravel" then and only then do you run composer update.
composer update is what updates the framework (vendor stuff).
However in my 6 to 7 I also had to run:
composer require laravel/ui "^2.0"
But backup everything first prior to updating / upgrading in case.
Many times it's as easy doing a fresh install and just migrate your code over, that's up to you.
What's the most stable release? 6.? ?
@cookie_good Laravel 6 has long term support (currently at 6.17.1 I believe). But they're all stable. Even if something slips through it's patched quickly.
@jlrdw I think what you're trying to say here is that changes need to be made to the Laravel application being built before upgrading the framework.
The way you put it just confuses one entirely. I spent some time trying to understand what you meant by "update Laravel first".
Then I realised you must be talking about the application being written. So the necessary breaking changes need to be made to the application before upgrading the Laravel framework version.
@chrisidakwo and @ignium I totally agree with your points. Although, I'm a regular visitor of Laracasts for finding the solutions and updates, I never really felt I should create an account. I just joined in to put my views here and thank you guys for sharing the "confusion" about the same problem 😁.
I found out @jlrdw's guide on what he "actually" means by "Update Laravel, then upgrade the framework" (even though, that's also a bit confusing - no offence):
https://laracasts.com/discuss/channels/guides/update-upgrade-laravel-then-framework
I just want to put this out if someone like me and many others find it really frustrating, updating their Laravel projects.
Please or to participate in this conversation.