前言
6.x是LTS,并开始使用6.x进行开发,但是预计下一个LTS版本会在发布时发布或即将发布,因此,在升级下一个版本时,我们降低成本。我将以
的感觉升级到8.x
更新前信息
PHP
1 2 3 4 5 | PHP 7.4.3 (cli) (built: Feb 20 2020 21:53:46) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans |
Laravel
1 | Laravel Framework 6.18.35 |
composer.json
- 由于它是我实际使用的PJ,因此有些库与更新无关。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | "require": { "php": "^7.4", "ext-fileinfo": "*", "ext-json": "*", "ext-pdo": "*", "ext-redis": "*", "aws/aws-sdk-php-laravel": "~3.0", "encore/laravel-admin": "^1.8", "fideloper/proxy": "^4.0", "guzzlehttp/guzzle": "^7.0", "lampager/lampager": "^0.4.0", "lampager/lampager-laravel": "^0.4.5", "laravel/framework": "^6.2", "laravel/tinker": "^2.0", "lcobucci/jwt": "^3.3", "vinkla/hashids": "^7.0" }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.6", "brianium/paratest": "^4.2", "deployer/deployer": "^6.8", "deployer/recipes": "^6.2", "facade/ignition": "^1.4", "friendsofphp/php-cs-fixer": "^2.16", "fzaninotto/faker": "^1.9.1", "laravel/telescope": "^3.2", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", "phpmd/phpmd": "^2.9", "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.5" } |
更改
参阅以下文档
-
从6.x升级到7.0
- https://readouble.com/laravel/7.x/ja/upgrade.html
-
从7.x升级到8.0
- https://readouble.com/laravel/8.x/ja/upgrade.html
PHP要求
这次是最初的PHP 7.4,因此没有特别的变化
Laravel依赖软件包更新
6至7
laravel /框架到^ 7.0
nunomaduro /合作至^ 4.1
phpunit / phpunit至^ 8.5
Laravel /修补^ 2.0
外墙/点火至^ 2.0
7至8
狂饮http /狂饮到^ 7.0.1
外墙/点火至^ 2.3.6
Laravel /框架到^ 8.0
Laravel / ui至^ 3.0
nunomaduro /合作至^ 5.0
将phpunit / phpunit更改为^ 9.0
更改了composer.json
- 可能需要处理Laravel的依赖库以外的其他库,因此对于每个PJ来说都更好。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | "require": { "php": "^7.4", "ext-fileinfo": "*", "ext-json": "*", "ext-pdo": "*", "ext-redis": "*", "aws/aws-sdk-php-laravel": "~3.0", "encore/laravel-admin": "^1.8", "fideloper/proxy": "^4.0", - "guzzlehttp/guzzle": "^7.0", + "guzzlehttp/guzzle": "^7.0.1", "lampager/lampager": "^0.4.0", "lampager/lampager-laravel": "^0.4.5", - "laravel/framework": "^6.2", + "laravel/framework": "^8.0", "laravel/tinker": "^2.0", + "laravel/ui": "^3.0", "lcobucci/jwt": "^3.3", - "vinkla/hashids": "^7.0" + "vinkla/hashids": "^9.0" }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.6", - "brianium/paratest": "^6.0", + "brianium/paratest": "^6.8", "deployer/deployer": "^6.8", "deployer/recipes": "^6.2", - "facade/ignition": "^1.4", + "facade/ignition": "^2.3.6", "friendsofphp/php-cs-fixer": "^2.16", "fzaninotto/faker": "^1.9.1", - "laravel/telescope": "^3.2", + "laravel/telescope": "^4.0", "mockery/mockery": "^1.0", - "nunomaduro/collision": "^3.0", + "nunomaduro/collision": "^5.0", "phpmd/phpmd": "^2.9", "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.5" } |
如果继续执行
1 2 3 4 5 | Writing lock file Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255 |
升级到Symfony 5
更改应用程序\\异常\\处理程序
-
复制具有8.x内容的
app/Exceptions/Handler.php -
我刚才称为家长处理的部分消失了
-
如果要保留它,请转到接收
Exception 的Throwable
-
如果要保留它,请转到接收
- 我希望我有自己的实现
https://github.com/laravel/laravel/blob/8.x/app/Exceptions/Handler.php
更改会话设置
-
复制具有8.x内容的
config/session.php - 除了评论以外,区别如下
- 我希望我有自己的实现
应用程序\\配置\\ session.php
1 2 3 4 5 6 7 8 9 10 11 | ~~ - 'secure' => env('SESSION_SECURE_COOKIE', false), + 'secure' => env('SESSION_SECURE_COOKIE'), ~~ - 'same_site' => null, + 'same_site' => 'lax', ]; |
https://github.com/laravel/laravel/blob/8.x/config/session.php
运行撰写更新
执行上述操作后,执行作曲家更新,如果没有错误,就可以了
如果发生错误,我认为最好查看内容并解决它
到目前为止的最低支持量
1 | $ composer update |
如果您喜欢
,请清除缓存
1 | $ artisan optimize:clear |
更新版本
1 | Laravel Framework 8.16.1 |
下一步
根据环境的不同,上述措施还不够,因此在检查操作时,请参考升级指南中有关错误或行为异常的部分。
特别检查"可能的影响:高"部分
-
从6.x升级到7.0
- https://readouble.com/laravel/7.x/ja/upgrade.html
-
从7.x升级到8.0
- https://readouble.com/laravel/8.x/ja/upgrade.html
作为参考,即使它说"可能的影响:低",我在PJ中使用了
由于更新库的影响,我被迫在与Laravel不相关的地方进行更新
查看代码差异可能比查看升级指南更快。
https://github.com/laravel/laravel/compare/6.x...8.x