如何将Laravel从5.7升级到5.8

时间:2019-10-30 23:22:39

标签: laravel composer-php laravel-5.8

我已经在谷歌上搜索了几天了。 由于依赖关系,我无法将Laravel项目从5.7更新到5.8。当我在composer.json中更新依赖包版本值并尝试执行laravel更新时,它会忽略我的更新,并实际上将其还原为原始值。

Composer.json

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": "^7.1.3",
    "anhskohbo/no-captcha": "^3.0",
    "chriskonnertz/open-graph": "^1.0",
    "cmgmyr/messenger": "^2.16",
    "cviebrock/eloquent-sluggable": "^4.6",
    "doctrine/dbal": "^2.8",
    "egeloen/http-adapter": "^1.0",
    "eilander/gateway": "^5.6",
    "exodusanto/administrator": " 5.7.*",
    "fideloper/proxy": "^4.0",
    "fzaninotto/faker": "^1.8",
    "geocoder-php/bing-maps-provider": "^4.0",
    "geocoder-php/chain-provider": "^4.0",
    "geocoder-php/google-maps-provider": "^4.2",
    "geoip2/geoip2": "^2.9",
    "hemp/presenter": "^1.0",
    "hieu-le/active": "^3.5",
    "htmlmin/htmlmin": "^5.8",
    "intervention/image": "^2.4",
    "laravel/framework": "5.7.*",
    "laravel/passport": "^7.0",
    "laravel/socialite": "^4.1",
    "laravel/tinker": "^1.0",
    "laravelcollective/html": "^5.7",
    "league/period": "4.1.0",
    "maatwebsite/excel": "^3.1",
    "morrislaptop/laravel-queue-clear": "^1.1",
    "php-http/guzzle6-adapter": "^1.1",
    "php-http/message": "^1.7",
    "phpoffice/phpspreadsheet": "^1.5",
    "pragmarx/firewall": "^2.2",
    "predis/predis": "^1.1",
    "prettus/l5-repository": "^2.6",
    "prettus/laravel-validation": "^1.1",
    "ryanwinchester/hubspot-php": "~1.0",
    "sammyk/laravel-facebook-sdk": "^3.5",
    "santigarcor/laratrust": "^5.0",
    "spatie/laravel-newsletter": "^4.2",
    "toin0u/geocoder-laravel": "^4.0",
    "torann/geoip": "^1.0",
    "venturecraft/revisionable": "^1.28",
    "watson/sitemap": "^2.0",
    "yajra/laravel-datatables-oracle": "^8.9"
},
"require-dev": {
    "beyondcode/laravel-dump-server": "^1.0",
    "filp/whoops": "^2.0",
    "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

}

我采取的步骤:

1)编辑我的composer.json文件,更改为:“ laravel / framework”:“ 5.7。
到:“ laravel / framework”:“ 5.8。

2)运行作曲家更新

输出:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package egeloen/http-adapter is abandoned, you should avoid using it. Use php-http/httplug instead.
Generating optimized autoload files
Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run ".\vendor\bin\upgrade-carbon" to get help in updating carbon and other frameworks and libraries that depend on it.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: anhskohbo/no-captcha
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: chriskonnertz/open-graph
Discovered Package: cmgmyr/messenger
Discovered Package: cviebrock/eloquent-sluggable
Discovered Package: exodusanto/administrator
Discovered Package: fideloper/proxy
Discovered Package: hemp/presenter
Discovered Package: hieu-le/active
Discovered Package: htmlmin/htmlmin
Discovered Package: intervention/image
Discovered Package: laravel/nexmo-notification-channel
Discovered Package: laravel/passport
Discovered Package: laravel/slack-notification-channel
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravelcollective/html
Discovered Package: maatwebsite/excel
Discovered Package: morrislaptop/laravel-queue-clear
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: pragmarx/firewall
Discovered Package: prettus/l5-repository
Discovered Package: sammyk/laravel-facebook-sdk
Discovered Package: santigarcor/laratrust
Discovered Package: spatie/laravel-newsletter
Discovered Package: toin0u/geocoder-laravel
Discovered Package: torann/geoip
Discovered Package: watson/sitemap
Discovered Package: yajra/laravel-datatables-oracle
Package manifest generated successfully.

结果:

composer.json文件已重置为显示:“ laravel / framework”:“ 5.7。*”

我尝试过的事情: 1)尝试执行此操作之前,请删除composer.lock文件。 2)执行php artisan缓存:在我进行更新之前请先清除。

必须有一个经历过这些问题的人可以帮助我。

3 个答案:

答案 0 :(得分:3)

只需遵循Official Upgrade Guide

  1. 将您的composer.json laravel/framework更新为5.8.*
  2. 运行composer update。无需删除`composer.lock
  3. 查看上面的升级指南,了解可能会影响您的应用程序的更改。此版本几乎没有重大更改。

答案 1 :(得分:0)

结果表明,IDE(Eclipse Neon)从未更新过我的composer.json文件,即使它表明我正在这样做。我从命令行对其进行了编辑,并且可以正常工作。

答案 2 :(得分:-1)

我在这种情况下的亲身经历使我学会了使用新版本的Laravel创建一个全新的项目,然后添加我的个人更改(即控制器,模型,迁移,视图,配置等)。当然,使用单元测试将极大地帮助您成功地将项目升级到下一个级别。

顺便说一句。 this link可以帮助您安全地进行升级,但是我再次强烈建议您使用全新的安装方式,而不要处理任何更改。