LoginSignup
10
10

More than 5 years have passed since last update.

Laravel 5.2 へアップグレード(From Laravel 5.1)

Posted at

リクエストarrayをバリデーションするときに困っていたのですが、
Laravel5.2 で Validating Arrays が実装されたとアドバイスいただきました。

【Laravel5.1】 arrayの中身をバリデーションする

なので、5.2にアップデートしたので、そのときやった手順をまとめておきます。ハマったところ含め。
なお、↓が正式ドキュメント。
Upgrading To 5.2.0 From 5.1

1.comporser.json の修正

やることは、2つ。
 1-1. laravel を 5.2 に。
 1-2. reture_devに設定追加。

coposer.json
...
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*", // <-変更
...
    "require-dev": {
        ....
        "symfony/dom-crawler": "~3.0", // <-追加
        "symfony/css-selector": "~3.0" // <-追加

2. composer update 実行

ドキュメント見る限り、composer update すればOKと思っていたが、エラー。
以下の2つを解消して、実行完了。

エラー対応1:composerを最新に←

エラー内容。

[RuntimeException] Could not load package intervention/image in http://packagist.org: [UnexpectedValueException] Could not parse version constraint 4.x.x: Invalid version string "4.x.x"

composerが最新でない模様。
$ composer self-update
で解決。

エラー対応2:app.phpから不要なものを削除

[RuntimeException]

Error Output: Xdebug requires Zend Engine API version 220121212. The Zend Engine API version 220131226 which is installed, is newer. Contact Derick Rethans at http://xdebug.org/docs/faq#api for a later version of Xdebug.

PHP Fatal error: Class 'Illuminate\Routing\ControllerServiceProvider' not found in /vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

config/app.php が原因でした。
以下の2つが5.2から必要なくなったので削除。
Illuminate\Routing\ControllerServiceProvider::class
Illuminate\Foundation\Providers\ArtisanServiceProvider::class

3. ログイン画面の表示

サーバー立ち上げてアクセスしたら叱られる。

exception 'InvalidArgumentException' with message 'Auth guard [] is not defined.' in /vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php:73

原因は、auth.phpの変更をしていなかったこと。Multi-Authが実装されたってことはちらっと知ってたのに。

5.2のauth.php↓を参照して対応したら表示できた。
https://github.com/laravel/laravel/blob/v5.2.0/config/auth.php

4. ログイン

カスタムドライバを使ってたのですが、これが原因でログインできず。
ちゃんと読めって話ですが、5.2のドキュメントにちゃんと書いてあった。

Custom Drivers

If you are using the Auth::extend method to define a custom method of retrieving users, you should now use Auth::provider to define your custom user provider. Once you have defined the custom provider, you may configure it in the providers array of your new auth.php configuration file.

Auth::extend を Auth::provider に変更して再度実施。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10