【问题标题】:How to Upgrade from laravel 5.2 to 5.4?如何从 laravel 5.2 升级到 5.4?
【发布时间】:2017-12-03 02:37:24
【问题描述】:

我想将 Laravel 更新到最新版本 5.4。
但是laravel migration guide中没有给出直接迁移,所以我首先尝试将它迁移到laravel 5.3。
我的项目正在开发 5.2 laravel 版本并尝试升级它。

我已按照 laravel 迁移指南文档的指导更新了 composer.json
并在命令行运行命令composer update

我收到以下错误。

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Loading composer repositories with package information

更新依赖(包括require-dev) 您的需求无法解析为一组可安装的软件包。

Problem 1
    - Conclusion: don't install laravel/framework v5.3.31
    - Conclusion: don't install laravel/framework v5.3.30
    - Conclusion: don't install laravel/framework v5.3.29
    - Conclusion: don't install laravel/framework v5.3.28
    - Conclusion: don't install laravel/framework v5.3.27
    - Conclusion: don't install laravel/framework v5.3.26
    - Conclusion: don't install laravel/framework v5.3.25
    - Conclusion: don't install laravel/framework v5.3.24
    - Conclusion: don't install laravel/framework v5.3.23
    - Conclusion: don't install laravel/framework v5.3.22
    - Conclusion: don't install laravel/framework v5.3.21
    - Conclusion: don't install laravel/framework v5.3.20
    - Conclusion: don't install laravel/framework v5.3.19
    - Conclusion: don't install laravel/framework v5.3.18
    - Conclusion: don't install laravel/framework v5.3.17
    - Conclusion: don't install laravel/framework v5.3.16
    - Conclusion: don't install laravel/framework v5.3.15
    - Conclusion: don't install laravel/framework v5.3.14
    - Conclusion: don't install laravel/framework v5.3.13
    - Conclusion: don't install laravel/framework v5.3.12
    - Conclusion: don't install laravel/framework v5.3.11
    - Conclusion: don't install laravel/framework v5.3.10
    - Conclusion: don't install laravel/framework v5.3.9
    - Conclusion: don't install laravel/framework v5.3.8
    - Conclusion: don't install laravel/framework v5.3.7
    - Conclusion: don't install laravel/framework v5.3.6
    - Conclusion: don't install laravel/framework v5.3.5
    - Conclusion: don't install laravel/framework v5.3.4
    - Conclusion: don't install laravel/framework v5.3.3
    - Conclusion: don't install laravel/framework v5.3.2
    - Conclusion: don't install laravel/framework v5.3.1
    - laravelcollective/html v5.4 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.1 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.2 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.3 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.4 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.5 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.6 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.7 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravelcollective/html v5.4.8 requires illuminate/view 5.4.* -> satisfiable by illuminate/view[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - don't install illuminate/view v5.4.0|don't install laravel/framework v5.3.0
    - don't install illuminate/view v5.4.13|don't install laravel/framework v5.3.0
    - don't install illuminate/view v5.4.17|don't install laravel/framework v5.3.0
    - don't install illuminate/view v5.4.19|don't install laravel/framework v5.3.0
    - don't install illuminate/view v5.4.27|don't install laravel/framework v5.3.0
    - don't install illuminate/view v5.4.9|don't install laravel/framework v5.3.0
    - Installation request for laravel/framework 5.3.* -> satisfiable by laravel/framework[v5.3.0, v5.3.1, v5.3.10, v5.3.11, v5.3.12, v5.3.13, v5.3.14, v5.3.15, v5.3.16,
v5.3.17, v5.3.18, v5.3.19, v5.3.2, v5.3.20, v5.3.21, v5.3.22, v5.3.23, v5.3.24, v5.3.25, v5.3.26, v5.3.27, v5.3.28, v5.3.29, v5.3.3, v5.3.30, v5.3.31, v5.3.4, v5.3.5, v5.
3.6, v5.3.7, v5.3.8, v5.3.9].
    - Installation request for laravelcollective/html ~5.4 -> satisfiable by laravelcollective/html[v5.4, v5.4.1, v5.4.2, v5.4.3, v5.4.4, v5.4.5, v5.4.6, v5.4.7, v5.4.8].

我需要在 composer.json 中进行哪些额外更改才能使更新生效?

** 更新:**

这是composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.3.*",
        "twbs/bootstrap": "dev-master",
        "laravelcollective/html": "~5.4",
        "kepex/laravel-crud-generator": "^0.1.4",
        "watson/bootstrap-form": "^1.0",
        "doctrine/dbal": "^2.5",
        "intervention/image": "dev-master",
        "danvuquoc/laravel-kraken": "1.*",
        "barryvdh/laravel-dompdf": "0.8.*",
        "barryvdh/laravel-debugbar": "^2.2",
        "barryvdh/laravel-snappy": "^0.3.0",
        "danielboendergaard/phantom-pdf": "^1.2",
        "h4cc/wkhtmltopdf-i386": "0.12.x",
        "h4cc/wkhtmltoimage-i386": "0.12.x",
        "h4cc/wkhtmltopdf-amd64": "0.12.x",
        "knplabs/knp-snappy": "^0.4.3",
        "wemersonjanuario/wkhtmltopdf-windows": "0.12.2.3",
        "tymon/jwt-auth": "0.5.*",
        "zizaco/entrust": "dev-laravel-5",
        "eluceo/ical": "^0.11.0",
        "jurosh/pdf-merge": "dev-master",
        "torann/geoip": "^1.0",
        "maatwebsite/excel": "~2.1.0",
        "roumen/sitemap": "dev-master",
        "guzzlehttp/guzzle": "^6.2",
        "rackspace/php-opencloud": "dev-master",
         "ellisthedev/laravel-5-robots": "~0.1.0",
        "mpdf/mpdf": "^6.1",
        "matthiasmullie/minify": "^1.3",
        "lullabot/amp": "^1.0.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "symfony/css-selector": "2.8.*|3.0.*|3.1.*",
        "symfony/dom-crawler": "2.8.*|3.0.*|3.1.*"
    },
    "autoload": {
        "classmap": ["database"],
        "files": ["app/Http/helpers.php"],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": ["tests/TestCase.php"]
    },
    "scripts": {
        "post-root-package-install": ["php -r \"copy('.env.example', '.env');\""],
        "post-create-project-cmd": ["php artisan key:generate"],
        "post-install-cmd": ["Illuminate\\Foundation\\ComposerScripts::postInstall", "php artisan optimize"],
        "post-update-cmd": ["Illuminate\\Foundation\\ComposerScripts::postUpdate", "php artisan optimize"]
    },
    "config": {
        "preferred-install": "dist"
    }
}

【问题讨论】:

  • 您需要将 dompdf 包从 0.6.1 更新到最新版本。 "dompdf/dompdf": "^0.8" 更新 composer.json 中的版本
  • 运气不好,伙计。我也试过了。
  • 仍然出现同样的错误?还是其他包依赖版本问题?
  • 我已更新错误日志消息,请检查。那些错误消失了。现在还剩下一些
  • 更改为 "laravelcollective/html": "^5.3",因为 v5.4 需要 laravel framework v5.4

标签: php laravel laravel-5 migration


【解决方案1】:

最后我最终利用了link 的优势,因为这些人整合了所有可能的东西。只是我们这边的小改动,当他们升级最新版本的 laravel 时,他们也会在日志中提到。它是有偿的,但一次投资以节省时间是值得的。

【讨论】:

    【解决方案2】:

    我从 Laravel 5.2 迁移到 5.6.3 以下是我的步骤:

    首先,您需要更新提供程序app/Providers/{EventServiceProvider, RouteServiceProvider}.php
    他们的 boot() 方法不应该带参数:

         ...
    -    public function boot(DispatcherContract $events)
    +    public function boot()
         {
    -        parent::boot($events);
    +        parent::boot();
         }
         ...
    

    其次,更新您的 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.6.*",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "^5.5.0"
      },
      "require-dev": {
        "barryvdh/laravel-debugbar": "^3.1",
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "~1.0",
        "nunomaduro/collision": "~2.0",
        "phpunit/phpunit": "~7.0",
        "symfony/thanks": "^1.0",
        "doctrine/dbal": "^2.5"
      },
      "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
    }
    

    然后运行composer updatephp composer.phar update

    从原始存储库中替换您的 App/Providers/RouteServiceProvider.php。

    将您的路由从 app/routes/web.php 移动到 routes/web.php(最初,您可能还想从原始 Laravel 复制路由)

    从文件夹 app/Http/Controllers/Auth 中的原始 Laravel 存储库中替换用于身份验证的控制器

    注释掉旧的认证路由并在 web.php 路由文件 (more about this) 中添加 Auth::routes();

    从原始存储库添加config/hashing.php

    运行php artisan config:cache 重置缓存。

    最后,更新您的数据库结构php artisan migrate --seed 并运行应用程序php artisan serve

    Original Laravel Repository

    【讨论】:

    • 您今天从 5.2 迁移到 5.6 不需要做更多工作吗?我正在寻找一种方法来做到这一点?我正在阅读从 5.2 到 5.3 的更新,并且有很多步骤与您的方法相反?谢谢
    • 您能提供文章的链接吗?就我而言,我按照上述步骤成功迁移。
    【解决方案3】:

    我认为你需要试试这个:

    你也必须先更新 LaravelCollective html package

    在您的composer.json 中,替换:

    “laravelcollective/html”:“5.2.*”

    与:

    “laravelcollective/html”:“5.4.*”

    【讨论】:

    • 没有运气的伙伴同样的错误即将到来。但我注意到一件事,错误行已减少
    【解决方案4】:

    你必须更新第一个 barryvdh/laravel-dompdf 包。

    在您的 composer.json 更改中:

    第一次改变

    "laravel/framework": "5.3.*"到上一个

    然后改变

    来自

    "barryvdh/laravel-dompdf": "^0.6.1",
    

    "barryvdh/laravel-dompdf": "^0.8.0",
    

    然后点击composer update 命令

    然后更改"laravel/framework": "5.3.*"并再次点击

    `composer update`
    

    命令

    【讨论】:

    • 做一件事,首先将你的 "laravel/framework": "5.3.*" 更改为旧的,然后点击 composer update 命令。所以它会首先更新“barryvdh/laravel-dompdf”包而没有任何错误,然后更改“laravel/framework”:“5.3.*”
    • 实际上我想将 5.2 更新到 5.4,但指南中没有给出方向迁移。所以我首先尝试从 5.2 迁移到 5.3,然后从 5.3 迁移到 5.4。如果第一个有效
    • 只删除 laravelcollective/html": "~5.4", "barryvdh/laravel-dompdf": "^0.8.0",这两行,然后点击 composer update。
    • 看起来它可以工作,但最后它抛出 [ErrorException] App\Providers\EventServiceProvider::boot() 声明应该与 Illuminate\Foundation\Support\Providers\EventServiceProvider::boot 兼容()
    • stackoverflow.com/questions/40935130/… 得到?查看升级指南
    猜你喜欢
    • 1970-01-01
    • 2020-08-26
    • 1970-01-01
    • 2018-04-23
    • 1970-01-01
    • 2019-05-10
    • 2018-06-17
    • 2020-05-23
    • 1970-01-01
    相关资源
    最近更新 更多