During this quarantine time, I've decided to upgrade my website to Laravel 7 and then to 8. I've linked the Laravel docs below. I'll be including steps I followed from the docs along with other steps I needed for my setup.
Upgrading Laravel is a fairly straightforward process. You just need to make sure you have the proper requirements and follow the docs and the errors given when you run the upgrade command. That's really all there is to it. Mainly you update your
composer.json file to whatever the docs say. I upgraded from 6 to 7 first, and then from 7 to 8. I didn't go from 6 to 8, so I can't comment on how well that would work out, so I just recommend this approach.
Before you really start make sure you're using at least PHP 7.3.0. Here are the commands I followed on MacOS:
brew unlink email@example.com && brew remove firstname.lastname@example.org && brew uninstall --ignore-dependencies email@example.com
rm -rf 7.* (whichever versions you have that aren't 7.3)
brew install firstname.lastname@example.org
brew link email@example.com
When I upgraded from 6 to 7 earlier in quarantine, along with following the docs I had to edit my app/Exceptions/Handler.php file because I was getting errors. I made the following changes:
public function report(Throwable $exception);
public function shouldReport(Throwable $exception);
public function render($request, Throwable $exception);
public function renderForConsole($output, Throwable $exception);
Upgrading to 8 from 7 was easier. I didn't have to edit as much. Again, I just followed the docs and made the following extra changes for the Laravelium plugins I use for my setup in my
When you're finished with all of this, just run
composer update. Use
php artisan --version to make sure everything worked. At the time of this article, my setup says
Laravel Framework 8.10.0 when I run that command.
I'm running an Apache server so I followed these instructions and commands to update to PHP 7.3.0.
sudo apt install php7.3 php7.3-cli php7.3-common
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.3
sudo apt-get install php7.3-mysql
After you pull all your changes, run
php artisan --version again just to make sure everything you just did is live.
Now you should be good to go! Even though was easier for me to upgrade from 7 to 8 than it was from 6 to 7, each time really isn't that difficult. I think that's just a testament to how much work and consideration is put into Laravel. If you're looking for a new framework, I really recommend Laravel.