php artisan migrate で autoload_real.php のシンタックスエラーが出た話


## php artisan migrate でエラー
```sh
$ php artisan migrate
PHP Parse error:  syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting ']' in /home/vagrant/***/vendor/composer/autoload_real.php on line 71

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting ']' in /home/vagrant/***/vendor/composer/autoload_real.php on line 71
```

## composer update でもエラー
```sh
$ composer update

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 134217736 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSet.php on line 83

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 134217736 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSet.php on line 83

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.⏎ 
```

## composer i は成功するが、今度は autoload_static.php でエラー
```sh
$ composer i
# 成功
```

```sh
$ php artisan migrate
PHP Parse error:  syntax error, unexpected 'C' in /home/vagrant/***/vendor/composer/autoload_static.php on line 8765

Parse error: syntax error, unexpected 'C' in /home/vagrant/***/vendor/composer/autoload_static.php on line 8765
```

## /vendor/composer/autoload_static.php を削除
```sh
$ rm /vendor/composer/autoload_static.php
```
```sh
$ php artisan migrate
PHP Warning:  require_once(/home/vagrant/***/vendor/composer/autoload_static.php): failed to open stream: No such file or directory in /home/vagrant/***/vendor/composer/autoload_real.php on line 28

Warning: require_once(/home/vagrant/***/vendor/composer/autoload_static.php): failed to open stream: No such file or directory in /home/vagrant/***/vendor/composer/autoload_real.php on line 28
PHP Fatal error:  require_once(): Failed opening required '/home/vagrant/***/vendor/composer/autoload_static.php' (include_path='.:/usr/share/php') in /home/vagrant/***/vendor/composer/autoload_real.php on line 28

Fatal error: require_once(): Failed opening required '/home/vagrant/***/vendor/composer/autoload_static.php' (include_path='.:/usr/share/php') in /home/vagrant/***/vendor/composer/autoload_real.php on line 28
```

## /vendor/composer/autoload_real.php を削除
```sh
$ rm /vendor/composer/autoload_real.php
```
```sh
$ php artisan migrate
PHP Warning:  require_once(/home/vagrant/***/vendor/composer/autoload_real.php): failed to open stream: No such file or directory in /home/vagrant/***/vendor/autoload.php on line 5

Warning: require_once(/home/vagrant/***/vendor/composer/autoload_real.php): failed to open stream: No such file or directory in /home/vagrant/***/vendor/autoload.php on line 5
PHP Fatal error:  require_once(): Failed opening required '/home/vagrant/***/vendor/composer/autoload_real.php' (include_path='.:/usr/share/php') in /home/vagrant/***/vendor/autoload.php on line 5

Fatal error: require_once(): Failed opening required '/home/vagrant/***/vendor/composer/autoload_real.php' (include_path='.:/usr/share/php') in /home/vagrant/***/vendor/autoload.php on line 5
```

## composer i 再度実行で成功
```sh
$ composer i
$ php artisan migrate
# 成功
```

## 結論
`vender/composer/` 配下は composer によって自動生成されるので、その配下のファイルでエラーが出たら怖がらずに削除して、再度 composer i すればよし。