Laravelを 5.4 から 6.0.x にバージョンアップしてみた。

##【開発環境】
Amazon EC2 Linux
Windows 10 HOME
Apache/2.4.43
Laravel Framework 5.4.36
vsftpd: Ver 3.0.2

Tera Term 4.1.105
FFFTP Ver 4.7

##【何も考えずにやってみる】

調べたらcomposer.json　のlaravel/frameworkを修正して
composer update　すれば良いらしい。。

```
        "laravel/framework": "5.4.*",
↓
        "laravel/framework": "6.0.*",
```
バージョンを修正して

```
[ec2-user@ip-172-31-11-201 sample]$ composer update

```
composer update　実施。

```
Loading composer repositories with package information
Updating dependencies (including require-dev)

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 616570880) (tried to allocate 16777224 bytes) in phar:///usr/local/bin/composer/                                     src/Composer/DependencyResolver/RuleSet.php on line 83

Fatal error: Out of memory (allocated 616570880) (tried to allocate 16777224 bytes) in phar:///usr/local/bin/composer/src/C                                     omposer/DependencyResolver/RuleSet.php on line 83

```

なんかlaravelをインストール時に見たことのあるエラーメッセージ。
メモリ不足でswapの設定がいるらしい。

```
[ec2-user@ip-172-31-11-201 sample]$ free -m
              total        used        free      shared  buff/cache   available
Mem:            983         306         633           0          43         585
Swap:             0           0           0
[ec2-user@ip-172-31-11-201 sample]$ sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 30.911 s, 69.5 MB/s
[ec2-user@ip-172-31-11-201 sample]$ sudo chmod 600 /swapfile
[ec2-user@ip-172-31-11-201 sample]$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=489e0af0-c0b6-46e0-b2c1-051c0e09a09c
[ec2-user@ip-172-31-11-201 sample]$ sudo swapon /swapfile
[ec2-user@ip-172-31-11-201 sample]$
[ec2-user@ip-172-31-11-201 sample]$ free -m
              total        used        free      shared  buff/cache   available
Mem:            983         308          63           0         612         534
Swap:          2047           0        2047
```
Swapにメモリが割り振られたみたいなので、、

```
composer update
```
再び　「composer update」を実施。

```
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 15 installs, 18 updates, 5 removals
  - Removing symfony/polyfill-util (v1.17.1)
  - Removing symfony/polyfill-php70 (v1.17.1)
  - Removing symfony/polyfill-php56 (v1.17.1)
  - Removing mtdowling/cron-expression (v1.2.3)
  - Removing kylekatarnls/update-helper (1.2.1)
  - Installing phpoption/phpoption (1.7.4): Downloading (100%)
  - Updating vlucas/phpdotenv (v2.6.5 => v3.6.6): Downloading (100%)
  - Installing symfony/polyfill-php80 (v1.17.1): Downloading (100%)
  - Installing symfony/polyfill-php72 (v1.17.0): Downloading (100%)
  - Updating symfony/var-dumper (v3.4.42 => v4.4.10): Downloading (100%)
  - Updating symfony/routing (v3.4.42 => v4.4.10): Downloading (100%)
  - Updating symfony/process (v3.4.42 => v4.4.10): Downloading (100%)
  - Installing symfony/polyfill-php73 (v1.17.1): Downloading (100%)
  - Installing symfony/polyfill-intl-idn (v1.17.1): Downloading (100%)
  - Installing symfony/mime (v5.1.2): Downloading (100%)
  - Updating symfony/http-foundation (v3.4.42 => v4.4.10): Downloading (100%)
  - Updating symfony/event-dispatcher-contracts (v1.1.7 => v1.1.9): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Updating symfony/debug (v3.4.42 => v4.4.10): Downloading (100%)
  - Installing symfony/error-handler (v4.4.10): Downloading (100%)
  - Updating symfony/http-kernel (v3.4.42 => v4.4.10): Downloading (100%)
  - Updating symfony/finder (v3.4.42 => v4.4.10): Downloading (100%)
  - Installing symfony/service-contracts (v2.1.3): Downloading (100%)
  - Updating symfony/console (v3.4.42 => v4.4.10): Downloading (100%)
  - Installing symfony/polyfill-iconv (v1.17.1): Downloading (100%)
  - Installing doctrine/lexer (1.2.1): Downloading (100%)
  - Installing egulias/email-validator (2.1.18): Downloading (100%)
  - Updating swiftmailer/swiftmailer (v5.4.12 => v6.2.3): Downloading (100%)
  - Updating paragonie/random_compat (v2.0.18 => v9.99.99): Downloading (100%)
  - Installing psr/simple-cache (1.0.1): Downloading (100%)
  - Installing opis/closure (3.5.5): Downloading (100%)
  - Updating symfony/translation-contracts (v1.1.7 => v2.1.3): Downloading (100%)
  - Updating symfony/translation (v4.3.11 => v4.4.10): Downloading (100%)
  - Updating nesbot/carbon (1.39.1 => 2.36.1): Downloading (100%)
  - Updating monolog/monolog (1.25.4 => 2.1.0): Downloading (100%)
  - Installing dragonmantank/cron-expression (v2.3.0): Downloading (100%)
  - Updating laravel/framework (v5.4.36 => v6.0.4): Downloading (100%)
  - Updating webmozart/assert (1.9.0 => 1.9.1): Downloading (100%)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
symfony/service-contracts suggests installing symfony/service-implementation
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
Deprecation Notice: Class App\Http\Controllers\BookController located in ./app/Http/Controllers/@BookController.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Warning: Ambiguous class resolution, "App\Http\Controllers\BookController" was found in both "/var/www/html/sample/app/Http/Controllers/@BookController.php" and "/var/www/html/sample/app/Http/Controllers/BookController.php", the first will be used.
33 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!

In Route.php line 917:

  Unable to prepare route [api/user] for serialization. Uses Closure.


Script php artisan optimize handling the post-update-cmd event returned with error code 1

```

```
[ec2-user@ip-172-31-11-201 sample]$ php artisan --version
Laravel Framework 6.0.4
```
確かにLaravelのバージョンが上がっています。

##【感想】
今回のLaravelのアップデートは最小構成の状態で行ったために
使っていないパッケージでメッセージ等は特に気にしなくていいようです。

これから大きなシステムにしてくとアップデートの度に
色々修正する箇所が増えると思うので日々自分自身もアップデートが必要かなと。


##【参考】

[ メモリ不足でLaravelインストールcomposer update失敗](https://qiita.com/ntm718/items/88d3fc787f4f18ad1f20)

[Laravelでcomposer updateするとPackage jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.](https://qiita.com/nasubi987/items/8c49bc3e5ec0df45f776)