001-laravel 5.3 升级到 laravel 5.5

96
霄峰
2019.05.04 00:10* 字数 349

记录升级时的问题与执行步骤

第一步 修改composer.json(项目根目录下)配置:

...
    "require": {
        ...
        "laravel/framework": "5.5.*",
        ...
     }
...
    "require-dev": {
        ...
        "phpunit/phpunit": "^7.0",
        ...
     }
...

第二步 执行更新并删除缓存、文件

composer update -vvv
composer update
chmod 777 -R storage/
chmod 777 -R bootstrap/cache/
composer dump-autoload
php artisan clear-compiled
php artisan view:clear #避免与删除 Illuminate\View\Factory::getFirstLoop() 相关的 Blade 错误
php artisan route:clear
php artisan cache:clear
php artisan config:clear
rm -rf  bootstrap/cache/compiled.php #删除编译的服务文件 它不再被框架使用。

第三步 Redis 集群支持。

如果你正在使用 Redis 集群,则应该将集群连接置于config/database.php配置文件的 Redis 部分中的 clusters 配置选项内

原来:

    'redis' => [

        'cluster' => true,

        'default' => [
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],
    ],

修改为:

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than a typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'cluster' => true,

        'client' => 'predis',

        'options' => [
            'cluster' => 'redis',
        ],

        'clusters' => [
            'default' => [
                [
                    'host' => env('REDIS_HOST', '127.0.0.1'),
                    'password' => env('REDIS_PASSWORD', null),
                    'port' => env('REDIS_PORT', 6379),
                    'database' => 0,
                ],
            ],
        ],
    ],

第四步 Markdown 邮件组件

你需要添加如下区域配置到 config/mail.php 配置文件底部:

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

遇到的问题

问题1

Package phpoffice/phpexcel is abandoned, you should avoid using it. Use phpoffice/phpspreadsheet instead.

phpoffice/phpexcel 弃用。升级为phpoffice/phpspreadsheet。在composer.json中没有直接使用phpoffice/phpexcel组件,于是查找依赖它的组件:

composer depends phpoffice/phpexcel

结果为:

maatwebsite/excel  2.1.20  requires  phpoffice/phpexcel (1.8.*)  

于是将maatwebsite/excel版本升级^3.0,编辑composer.json:

    "require": {
        ...
       "maatwebsite/excel": "^3.0",
        ...
     }

然后执行升级,参考:前面第二步 执行更新并删除缓存、文件


问题2

Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.

phpunit/phpunit-mock-objects 弃用。在composer.json中没有直接使用phpunit/phpunit-mock-objects组件,于是查找依赖它的组件:

composer depends phpunit/phpunit-mock-objects

结果为:

phpunit/phpunit  5.7.21  requires  phpunit/phpunit-mock-objects (^3.2)

于是将phpunit/phpunit版本升级^3.0,编辑composer.json:

    "require-dev": {
        ...
       "phpunit/phpunit": "^7.0",
        ...
     }

然后执行升级,参考:前面第二步 执行更新并删除缓存、文件


laravel 5.5中没有tinker,可以自行安装:

安装Laravel Tinker
为了继续使用 tinker Artisan 命令,你还应该安装 laravel/tinker 包:

composer require laravel/tinker
laravel & lumen