skip to Main Content

I have a Laravel 8.x project that have been running on PHP 7.4 for a couple of years now and I would like to start planning the upgrade for Laravel to v9.x and v10.x. Before upgrading Laravel I thought I would upgrade the server to PHP 8.1 for the time being because I am not rushing.

Excluding the server work involved for configuring PHP 8.1 with the same config as PHP 7.4, as far as I am concerned on Laravel side it is just a matter of running composer update right?

Here is a snippet of the project composer.json file for reference:

    "require": {
        "php": "^7.3|^8.0",
        "backpack/crud": "^5.0",
        "calebporzio/parental": "^0.11.0",
        "doctrine/dbal": "^2.8",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "google/apiclient": "^2.12",
        "intervention/image": "^2.5",
        "laravel/cashier": "^13.0",
        "laravel/framework": "^8.0",
        "laravel/passport": "^10.0",
        "laravel/tinker": "^2.5",
        "predis/predis": "^1.1",
        "rollbar/rollbar-laravel": "^7.0",
        "spatie/laravel-http-logger": "^1.7",
        "mixpanel/mixpanel-php" : "2.*"
    },
    "require-dev": {
        "backpack/generators": "^3.0",
        "facade/ignition": "^2.5",
        "fzaninotto/faker": "^1.9",
        "mockery/mockery": "^1.4",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3"
    }

P/S: I am also going to replace predis with php-redis and fzaninotto/faker with fakerphp/faker.

2

Answers


  1. Composer update is the first step to upgrade dependencies including Laravel in your project.

    Also, you need to check your code syntax and functions for matching patterns and is runnable with PHP 8. Because in previous PHP versions, there are many changes as compared with PHP 8 versions.

    You can check changes in php 8 compare with php 7 or old versions of php

    So be careful during upgrade your Laravel from 8 to 9 or 10. Because it will cause an errors if your code is not working in php 8 versions.

    Login or Signup to reply.
  2. Yes, update the values in your composer.json will get you where you need to go.
    However, there are a few other things that you will need to do – For example –
    "fruitcake/laravel-cors": "^2.0" – It might be worth giving the following a read as this will need removing and editing in places https://github.com/fruitcake/laravel-cors
    There is more information about this at the top of the github readme.

    The PHP Version will need editing too in your composer.json

    The Laravel docs has some good information regarding what you need to do on each update – If you’re going to laravel 10 follow the 8 to 9 and then 9 to 10 to make the upgrade easier. – https://laravel.com/docs/9.x/upgrade

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search