LoginSignup
37
22

More than 5 years have passed since last update.

Laravel 5.6 Release & 5.5 機能差分メモ

Posted at

おめでとうございます。どうも laracon に合わせてリリース。

所々で力尽きてるので。

  1. 5.6 Upgrade Guide
  2. ChangeLog 5.6
  3. Laravel 5.6 is Live, Here’s What’s New!

大きな変更点は Argon のサポート、 Log まわりの内部変更、Bootstrap4 対応

PHP上の変更点

  1. PHP >= 7.0.0 から PHP >= 7.1.3 になりました。

配列

  1. Arr::wrap メソッドの返り値が null から [] になりました

Artisan

  1. optimize が廃止されます。

Blade

e メソッドで htmlspecialcharsメソッドを通すが、Inline-JSONでJavascriptFrameworkを使うと二重……???

あとで書く

Blade Component Alias

Bladeのコンポーネントにエイリアス名をつけられるようになった。

  1. resources/views/components/alert.blade.php にコンポーネントの内容を書いたとする。
  2. Blade::component('components.alert', 'alert'); というコードをどっかに書く( ViewServiceProvider とか作ってそこのbootとかにやろか)
  3. Blade内で書くにはこんな感じになる
@component('alert')
    <p>This is an alert component</p>
@endcomponent

Cache

The Rate Limiter tooManyAttempts Method の挙動変更?

Cron

Cron実行をいくつかのサーバで実行している場合、全てのサーバで実行されますが、 onOneServerメソッドでどれか一つのサーバのみで実行できるようになった。

この機能を使うには、memcachedorredisサーバをキャッシュサーバとして使っている必要がある。

Database

Morph カラムのインデックス化。

morphsを使ったカラムのマイグレーションをした時に、パフォーマンスを良くするために実行予約が逆転していました(訳:あやしい)
もし mophsメソッドを一つのマイグレーションで使っている場合、migrationdownを実行した時にエラーが発生したと思われます。もし開発中のアプリケーションに起きた時、migrate:freshを実行して再構築をしていたはずです。Production環境の場合、morphsメソッドのインデックス名からパスするでしょう

MigrationRepositoryInterface

新しいgetMigrationsBatchesメソッドがMigrationRepositoryInterfaceに追加されました。

In the very unlikely event that you were defining your own implementation of this class, you should add this method to your implementation. You may view the default implementation in the framework as an example.

Eloquent

getDateFormatメソッドが、protectedからpublicになりました。

Hashing

config/hashing.phpファイルが追加されました。設定ファイルの中身は default configurationにして下さい。

Most likely, you should maintain the bcrypt driver as your default driver. However, argon is also supported.

Argon2i

Laravel では Argon2i アルゴリズムを使う。詳しくはこちら

Helpers

e 関数の挙動変更。

Logging

  1. 新しい設定ファイル

    config/logging.php ファイルが追加されました。設定ファイルの中身は default configurationにしてください。

    そしてconfig/app.phpの設定にあった log,log_levelは削除されます。

  2. configureMonologUsingメソッド

    もしあなたのアプリケーションが configureMonologUsing を使っている場合、custom ログチャンネルを新設する必要があります。詳しいことは こちら

  3. Writerクラス

    Illuminate\Log\WriterクラスはIlluminate\Log\Loggerへ名前変更されます。type-hintingでこのクラスを使っている場合は名前の変更をするようにして下さい。もしくは、どちらかと言えば、type-hintingでもPsr\Log\LoggerInterfaceを使うようにしてください。

  4. Illuminate\Contracts\Logging\Logインターフェース

    Illuminate\Contracts\Logging\Logインターフェースは廃止されます。type-hintingとして使うならPsr\Log\LoggerInterfaceを使うようにしてください。

Mail

Pagination

Bootstrap4 に対応しました。Bootstrap3 のリンクを使う場合は Paginator::useBootstrapThreeAppServiceProvider::boot メソッド内で実行して下さい。

Resources

EloquentのResource Response の origialプロパティが、新しくJsonの string/array になりました。modelデータの情報を早く確認する方法ができたっぽい。

Routing

Model を新しく作った時の返り値が自動的に 201 になります。アプリケーションテストで 200 が帰ってくるとしている場合は 201 に書き換えてね。

Trusted Proxies

Validation

ValidatesWhenResolved interface/trait の validateメソッド が、$request->validate()との衝突を回避するために validateResolved へ名前が変更されました。

Str

UUID メソッドが使えるようになりました。

(string) Str::uuid();(string)Str::orderedUuid()

orderedUuid

このメソッドは timestamp からUUIDを生成します。そしてDBのインデックスに効率がいい感じにするぽいよ。

37
22
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
37
22