Upgrading Laravel 5.4 to latest version (5.7)

后端 未结 8 1672
再見小時候
再見小時候 2021-02-14 12:13

I am working on Laravel 5.4 with PHP version 5.6.4. My goal is to upgrade my project to Laravel 5.7 with PHP 7.1.

Now my question is: Do I have to upgrade to 5.5 > 5.6 >

相关标签:
8条回答
  • 2021-02-14 12:28

    You can just update your laravel/framework dependency to 5.7.* in your composer.json file.

    1. change in composer.json:

    From:

    "require": {
            "php": ">=7.0.0",
            "fideloper/proxy": "~3.3",
            "laravel/framework": "5.4.*",
            "laravel/tinker": "~1.0"
        },
    

    To:

    "require": {
            "php": ">=7.1.3",
            "fideloper/proxy": "~4.0",
            "laravel/framework": "5.6.*",
            "laravel/tinker": "~1.0"
        },
    

    2. Replace app\Http\Middleware\TrustedProxies.php file with contents below:

    <?php
    
    namespace App\Http\Middleware;
    
    use Illuminate\Http\Request;
    use Fideloper\Proxy\TrustProxies as Middleware;
    
    class TrustProxies extends Middleware
    {
        /**
         * The trusted proxies for this application.
         *
         * @var array
         */
        protected $proxies;
    
        /**
         * The headers that should be used to detect proxies.
         *
         * @var string
         */
        protected $headers = Request::HEADER_X_FORWARDED_ALL;
    }
    

    3. composer update

    composer update
    
    0 讨论(0)
  • 2021-02-14 12:31

    From my point of view, it would help to upgrade step by step. This helps to to see whether your application is already compatible with all changes that need to be made.

    If you upgrade to 5.7 directly and face larger problems due to the changes, your quickest option is to downgrade to 5.4 again.

    If you upgrade to 5.5 in the first step, you can make your application compatible to 5.5, test it thoroughly, deploy it, and start to test what needs to be done for the upgrade to 5.6.

    0 讨论(0)
  • No,you sholud not upgrade step by step, only you can do this : https://laravel.com/docs/5.7/upgrade

    0 讨论(0)
  • 2021-02-14 12:32

    Better to upgrade 5.5 first an then go with 5.6 and 5.7 because if you see in 5.5 and 5.6 upgrade guide there are some packages also need to upgrade so you better go with the step by step.

    • 5.4 to 5.5
    • 5.5 to 5.6
    • 5.6 to 5.7

    For older versions, you can look at

    • 5.3 to 5.4
    • 4.2 to 5.3
    0 讨论(0)
  • 2021-02-14 12:38

    Just update your laravel/framework dependency to 5.7.* in your composer.json file:

    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0"
    },
    

    After, run this command on your command prompt: composer update

    You will achieve success and your Larvael will change to version 5.7, more details are available on upgrade guide

    0 讨论(0)
  • 2021-02-14 12:43

    For updating Laravel 6.x (Which means any subversions to V6)
    Just run this command

    cd [laravel installation directory]
    composer update

    You must have composer installed on your VM or PC.

    For Linux users only:

    Composer directory must be owned by current user

    //Check ownership
    ls -la ~/ | grep ".composer"
    
    //If you don't own the directory
    chown -R [user]/[user] ~/.composer
    

    Message me on any social media @smitpatelx Or leave a comment if you need any help or if your usecase differ from the above.

    0 讨论(0)
提交回复
热议问题