将 Laravel 5.6 升级到 5.7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52109640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:01:12  来源:igfitidea点击:

Upgrade Laravel 5.6 to 5.7

laravellaravel-5.6laravel-5.7

提问by Udhav Sarvaiya

I want to upgrade Laravel to 5.7 because I need new features, but I can't find any easy way.

我想将 Laravel 升级到 5.7,因为我需要新功能,但我找不到任何简单的方法。

I followed these steps:-Upgrading Laravel Versionbut I found an error during composer update

我按照以下步骤操作:-升级 Laravel 版本,但在Composer更新期间发现错误

I got this errorand I also tried to solve the solution but it is not working

我收到此错误,我也尝试解决该解决方案但它不起作用

My composer.json file:

我的 composer.json 文件:

    {
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

How do I upgrade Laravel 5.6 to 5.7 with full instructions?

如何使用完整说明将 Laravel 5.6 升级到 5.7?

回答by Dexter Bengil

Just update your laravel/frameworkdependency to 5.7.*in your composer.jsonfile. Since you are upgrading from 5.6to 5.7then, you can easily just run composer update

只需在您的文件中更新您的laravel/framework依赖项即可。由于您正在升级到那时,您可以轻松地运行5.7.*composer.json5.65.7composer update

And if you were doing custom modifications in your 5.6application, then you can check the Upgrade Guidefor a more detailed info.

如果您在5.6应用程序中进行自定义修改,则可以查看升级指南以获取更详细的信息。

回答by Rajkumar Sharma

I just upgrade laravel to 5.8 with following simple steps:

我只是通过以下简单步骤将 laravel 升级到 5.8:

  1. update in composer.json with "laravel/framework": "5.8.*",enter image description here
  2. Then in console run composer update
  3. Then some library cause problem like in my case yajra/laravel-datatables-oracleenter image description here
  4. Remove line from composer.json file "yajra/laravel-datatables-oracle": "~8.0",
  5. Again in console composer update
  6. Then last Error will be in trustedproxy.phpin line 66 enter image description hereto get rid from this error:

    a. Remove file trustedproxy.phpfrom configfolder of project b. Remove line "fideloper/proxy": "~3.3"c. Again in console composer update

  7. At this point there is error so at last add all the library that we remove before In my case, I in console composer require yajra/laravel-datatables-oracleand composer require fideloper/proxythen at last composer updatein console. That's it, hope this help someone.
  1. 在 composer.json 中更新并在"laravel/framework": "5.8.*",此处输入图像描述
  2. 然后在控制台运行 composer update
  3. 然后某些库会导致问题,例如在我的情况下yajra/laravel-datatables-oracle在此处输入图像描述
  4. 从 composer.json 文件中删除行 "yajra/laravel-datatables-oracle": "~8.0",
  5. 再次在控制台 composer update
  6. 然后最后一个错误将trustedproxy.php在第 66 行中 输入图像描述以摆脱此错误:

    一种。trustedproxy.phpconfig项目 b 的文件夹中删除文件。删除行"fideloper/proxy": "~3.3"c。再次在控制台composer update

  7. 此时出现错误,因此最后添加我们之前删除的所有库在我的情况下,我在控制台中composer require yajra/laravel-datatables-oraclecomposer require fideloper/proxy然后composer update在控制台中。就是这样,希望这对某人有所帮助。

回答by Tucker Wray

I followed a tutorial

我跟着教程

https://www.codementor.io/magarrent/how-to-install-laravel-5-xampp-windows-du107u9ji

https://www.codementor.io/magarrent/how-to-install-laravel-5-xampp-windows-du107u9ji

to install Laravel with Composer on windows. Being new to the PHP world, I didn't realize that 5.1 wasn't the newest version.

在 Windows 上使用 Composer 安装 Laravel。作为 PHP 世界的新手,我没有意识到 5.1 不是最新版本。

I couldn't find an easy way to uninstall it and reinstall or just upgrade to the newest version( at this point 5.8). kept getting errors :

我找不到一种简单的方法来卸载它并重新安装或升级到最新版本(此时是 5.8)。不断收到错误:

λ composer create-project laravel/laravel laravel "5.7."*

λ composer create-project laravel/laravel laravel "5.7."*

Installing laravel/laravel (v5.7.28) [InvalidArgumentException] Project directory laravel/ is not empty. enter mission change file name. &

安装 laravel/laravel (v5.7.28) [InvalidArgumentException] 项目目录 laravel/ 不为空。输入任务更改文件名。&

λ composer update

λ作曲家更新

Composer could not find a composer.json file in C:\xampp\htdocs To initialize a project, please create a composer.json file as described in the https://getcomposer.org/"Getting Started" section &

Composer 在 C:\xampp\htdocs 中找不到 composer.json 文件要初始化一个项目,请按照https://getcomposer.org/“入门”部分中的描述创建一个 composer.json 文件&

λ composer global remove laravel/installer

Changed current directory to C:/Users/lenovo/AppData/Roaming/Composer [RuntimeException] Could not read ./composer.json

file_get_contents(./composer.json): failed to open stream: No such file or directory

λ composer 全局删除 laravel/安装程序

将当前目录更改为 C:/Users/lenovo/AppData/Roaming/Composer [RuntimeException] 无法读取 ./composer.json

file_get_contents(./composer.json):无法打开流:没有那个文件或目录

I navigated in file explorer to:

我在文件资源管理器中导航到:

C:\xampp\htdocs

C:\xampp\htdocs

I :

一世 :

  1. navigate to C:\xampp\htdocs
  2. highlighted the laravel folder
  3. right click rename "laravel2"
  1. 导航到 C:\xampp\htdocs
  2. 突出显示 Laravel 文件夹
  3. 右键单击重命名“laravel2”

I repasted the install script in commandLine,this time with 5.8 in place of 5.1.

我在命令行中重播了安装脚本,这次用 5.8 代替了 5.1。

C:\xampp\htdocs λ composer create-project laravel/laravel laravel "5.8."*

C:\xampp\htdocs λ composer create-project laravel/laravel laravel "5.8."*

bingo

答对了

Delete the renamed file: "laravel2".

删除重命名的文件:“laravel2”。

"windows is moving 4888 files to recycle bin"

“windows 正在将 4888 个文件移动到回收站”