laravel6升级为laravel7教程以及问题总结

Song • 67 次浏览 • 0 个回复 • 2021年05月28日

laravel6升级为laravel7

Laravel 7 需要 PHP 7.2.5 或以上版本。

1、更新依赖

请更新在 composer.json 文件中以下依赖

"require": {
        "laravel/framework": "^7.0",
        "laravel/helpers": "^1.4",
        "laravel/tinker": "^2.0"
        ...

    },
    "require-dev": {
        "facade/ignition": "^2.0",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
        ...
    },

2、执行升级

composer update

出现的错误

1、未找到monolog

- Conclusion: don't install laravel/framework v7.30.3 (conflict analysis result)
- Conclusion: don't install laravel/framework v7.30.4 (conflict analysis result)
- Conclusion: don't install monolog/monolog 2.2.0 (conflict analysis result)

出现的问题是没有安装monolog,退回原来6.0的安装monolog即可。

composer require monolog/monolog

2、app/Exceptions/Handler.php异常

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
PHP Fatal error:  Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in /private/var/www/pinlebang/app/Exceptions/Handler.php on line 15
PHP Fatal error:  Uncaught ReflectionException: Class App\Exceptions\Handler does not exist in /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
Stack trace:
#0 /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct('App\\Exceptions\\...')
#1 /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\Container\Container->build('App\\Exceptions\\...')
#2 /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('App\\Exceptions\\...', Array, false)
#3 /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Container/Container.php(269): Illuminate\Foundation\Application->resolve('App\\Exceptions\\...', Array, false)
#4 /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->Illuminate\Container\{closure} in /private/var/www/pinlebang/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 811
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

解决办法

前往app/Exceptions/Handler.php文件,将所有Exception替换为Throwable

use Exception;
# 替换为
use Throwable;

-------------

Exception $exception
# 替换为
Throwable $exception

参考:laravel6到laravel7升级说明


原创文章,转载请注明 :laravel6升级为laravel7教程以及问题总结 - Laravel学习网
原文出处: https://phpartisan.cn/news/166.html
问题交流群 :168117787
提交评论
要回复文章请先登录注册
用户评论
  • 没有评论
[ 配置教程 ] 在ubuntu16.04中部署LNMP环境(php7+maridb且开启maridb远程以及nginx多域名访问 )并配置laravel环境 laravel出现无法清除缓存.确保您具有适当的权限(Failed to clear cache. Make sure you have the appropriate permissions.)