Readouble

Laravel 5.6 リリースノート

バージョニング規約Versioning Scheme

Laravelのバージョニングは、「パラダイム.メジャー・マイナー」の規約を維持しています。メジャーフレームワークリリースは、1月と6月の半年ごとにリリースします。一方、マイナーリリースは毎週のように、頻繁にリリースされます。マイナーリリースは、ブレーキングチェンジを絶対に含めません。Laravel's versioning scheme maintains the following convention: paradigm.major.minor. Major framework releases are released every six months (February and August), while minor releases may be released as often as every week. Minor releases should never contain breaking changes.

アプリケーションやパッケージで、Laravelフレームワークやコンポーネントを利用する場合、常に5.5.*のようにバージョンを指定してください。理由は上記の通り、Laravelのメジャーリリースは、ブレーキングチェンジを含んでいるからです。新しいメジャーリリースへの更新は、一日かからない程度になるように努力しています。When referencing the Laravel framework or its components from your application or package, you should always use a version constraint such as 5.5.*, since major releases of Laravel do include breaking changes. However, we strive to always ensure you may update to a new major release in one day or less.

パラダイムシフトリリースは数年空けています。これはフレームワークの構造と規約に重要な変更が起きたことを表します。現在、パラダイムシフトリリースは開発されていません。Paradigm shifting releases are separated by many years and represent fundamental shifts in the framework's architecture and conventions. Currently, there is no paradigm shifting release under development.

サポートポリシーSupport Policy

Laravel5.5のようなLTSリリースでは、バグフィックスは2年間、セキュリティフィックスは3年間提供します。これらのリリースは長期間に渡るサポートとメンテナンスを提供します。 一般的なリリースでは、バグフィックスは6ヶ月、セキュリティフィックスは1年です。For LTS releases, such as Laravel 5.5, bug fixes are provided for 2 years and security fixes are provided for 3 years. These releases provide the longest window of support and maintenance. For general releases, bug fixes are provided for 6 months and security fixes are provided for 1 year.

バージョンVersion リリースRelease バグフィックス期限Bug Fixes Until セキュリティフィックス期限Security Fixes Until
5.05.0 2015年2月4日February 4th, 2015 2015年8月4日August 4th, 2015 2016年2月4日February 4th, 2016
5.1 (LTS)5.1 (LTS) 2015年5月9日June 9th, 2015 2017年6月9日June 9th, 2017 2018年6月9日June 9th, 2018
5.25.2 2015年12月21日December 21st, 2015 2016年6月21日June 21st, 2016 2016年12月21日December 21st, 2016
5.35.3 2016年8月23日August 23rd, 2016 2017年2月23日February 23rd, 2017 2017年8月23日August 23rd, 2017
5.45.4 2017年1月24日January 24th, 2017 2017年7月24日July 24th, 2017 2018年1月24日January 24th, 2018
5.5 (LTS)5.5 (LTS) 2017年8月30日August 30th, 2017 2019年8月30日August 30th, 2019 2020年8月30日August 30th, 2020
5.65.6 2018年2月7日February 7th, 2018 2018年8月7日August 7th, 2018 2019年2月7日February 7th, 2019

Laravel 5.6Laravel 5.6

Laravel5.6はLaravel5.5からの持続的な向上に付け加え、向上したログシステム、単一サーバタスクスケジュール、向上したモデルのシリアライズ、動的レート制限、ブロードキャストチャンネルクラス、APIリソースコントローラ生成、Eloquent日付フォーマットの向上、Bladeコンポーネント別名、Argon2パスワードハッシュサポート、Collisionパッケージの同梱などを追加しました。更に、フロントエンドのスカフォールドは、Bootstrap4向けにアップグレードされました。Laravel 5.6 continues the improvements made in Laravel 5.5 by adding an improved logging system, single-server task scheduling, improvements to model serialization, dynamic rate limiting, broadcast channel classes, API resource controller generation, Eloquent date formatting improvements, Blade component aliases, Argon2 password hashing support, inclusion of the Collision package, and more. In addition, all front-end scaffolding has been upgraded to Bootstrap 4.

Laravelが背後で使用しているSymfonyコンポーネントは、Symfonyの~4.0リリースシリーズへアップグレードされました。All underlying Symfony components used by Laravel have been upgraded to the Symfony ~4.0 release series.

Laravel5.6のリリースはSpark6.0と同時にリリースされました。Laravel Sparkがリリースされてから、初めてのメジャーアップグレードです。Spark6.0では、StripeとBraintreeに対するユーザー数に応じた価格や、ローカリゼーション、Bootstrap4、UIの向上、Stripe Elementsのサポートを導入しました。The release of Laravel 5.6 coincides with the release of Spark 6.0[https://spark.laravel.com], the first major upgrade to Laravel Spark since its release. Spark 6.0 introduces per-seat pricing for Stripe and Braintree, localization, Bootstrap 4, an enhanced UI, and Stripe Elements support.

lightbulb">Tip!! このドキュメントはフレームワークで注目してもらいたい機能向上についてまとめたものです。より全体的な変更ログは、いつでもGitHubで確認できます。{tip} This documentation summarizes the most notable improvements to the framework; however, more thorough change logs are always available on GitHub[https://github.com/laravel/framework/blob/5.6/CHANGELOG-5.6.md].

ログの向上Logging Improvements

Laravel5.6ではログシステムが大いに向上しています。ログの設定はすべて、新しいconfig/logging.php設定ファイルにあります。ログメッセージを複数のハンドラへ送る、ログ「スタック」が簡単に構築できるようになりました。たとえば、debugレベルのメッセージは全てシステムログへ送り、errorレベルのメッセージでは、すぐに対応できるようにSlackへ送ることができます。Laravel 5.6 brings vast improvements to Laravel's logging system. All logging configuration is housed in the new config/logging.php configuration file. You may now easily build logging "stacks" that send log messages to multiple handlers. For example, you may send all debug level messages to the system log while sending error level messages to Slack so that your team can quickly react to errors:

'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['syslog', 'slack'],
    ],
],

さらに、新しいログシステムの"tap"機能を使えば、既存のログチャンネルを簡単にカスタマイズできるようになりました。詳細は、ログのドキュメント全文をご覧ください。In addition, it is now easier to customize existing log channels using the logging system's new "tap" functionality. For more information, check out the full documentation on logging[/docs/{{version}}/logging].

単一サーバタスクスケジュールSingle Server Task Scheduling

Note: note この機能を使用するには、アプリケーションのデフォルトキャッシュドライバとして、memcachedredisキャッシュドライバを使用する必要があります。更に、全サーバが同じ単一のキャッシュサーバと通信している必要があります。{note} To utilize this feature, your application must be using the memcached or redis cache driver as your application's default cache driver. In addition, all servers must be communicating with the same central cache server.

アプリケーションが複数のサーバで実行される場合、スケジュール済みのジョブを単一サーバ上のみで実行するよう制限できるようになりました。たとえば、毎週の金曜の夜に、新しいレポートを生成するタスクをスケジュールしていると仮定しましょう。タスクスケジューラが3つのワーカーサーバ上で実行されているなら、スケジュールされているタスクは3つ全部のサーバで実行され、3回レポートが生成されます。これではいけません。If your application is running on multiple servers, you may now limit a scheduled job to only execute on a single server. For instance, assume you have a scheduled task that generates a new report every Friday night. If the task scheduler is running on three worker servers, the scheduled task will run on all three servers and generate the report three times. Not good!

タスクをサーバひとつだけで実行するように指示するには、スケジュールタスクを定義するときにonOneServerメソッドを使用します。このタスクを最初に取得したサーバが、同じタスクを同じCronサイクルで他のサーバで実行しないように、ジョブにアトミックなロックを確保します。To indicate that the task should run on only one server, you may use the onOneServer method when defining the scheduled task. The first server to obtain the task will secure an atomic lock on the job to prevent other servers from running the same task on the same Cron cycle:

$schedule->command('report:generate')
         ->fridays()
         ->at('17:00')
         ->onOneServer();

動的レート制限Dynamic Rate Limiting

以前のLaravelのリリースでは、ルートのグループへレート制限を指定する場合、リクエストの最大回数をハードコードする必要がありました。When specifying a rate limit[/docs/{{version}}/routing#rate-limiting] on a group of routes in previous releases of Laravel, you were forced to provide a hard-coded number of maximum requests:

Route::middleware('auth:api', 'throttle:60,1')->group(function () {
    Route::get('/user', function () {
        //
    });
});

Laravel5.6では、認証されたUserモデルの属性にもとづいて、リクエストの最大回数が動的に指定されます。たとえば、Userモデルがrate_limit属性を含んでいれば、属性の名前をthrottleミドルウェアに指定することで、最大リクエストカウントを計算するために使用されます。In Laravel 5.6, you may specify a dynamic request maximum based on an attribute of the authenticated User model. For example, if your User model contains a rate_limit attribute, you may pass the name of the attribute to the throttle middleware so that it is used to calculate the maximum request count:

Route::middleware('auth:api', 'throttle:rate_limit,1')->group(function () {
    Route::get('/user', function () {
        //
    });
});

ブロードキャストチャンネルクラスBroadcast Channel Classes

アプリケーションで多くのチャンネルを利用していると、routes/channels.phpファイルは膨大になってしまいます。認証チャンネルのクロージャを使用する代わりに、チャンネルクラスを使用するのが良いでしょう。チャンネルクラスを生成するには、make:channel Aritisanコマンドが使用できます。このコマンドは、新しいチャンネルクラスをApp/Broadcastingディレクトリへ生成します。If your application is consuming many different channels, your routes/channels.php file could become bulky. So, instead of using Closures to authorize channels, you may now use channel classes. To generate a channel class, use the make:channel Artisan command. This command will place a new channel class in the App/Broadcasting directory.

php artisan make:channel OrderChannel

次に、チャンネルをroutes/channels.phpファイルで登録します。Next, register your channel in your routes/channels.php file:

use App\Broadcasting\OrderChannel;

Broadcast::channel('order.{order}', OrderChannel::class);

最後に、チャンネルの認証ロジックをチャンネルクラスのjoinへ記述します。典型的な場合ではチャンネル認証クロージャに設置するのと同じロジックをこのjoinメソッドに設置します。もちろん、チャンネルモデル結合の利点も利用できます。Finally, you may place the authorization logic for your channel in the channel class' join method. This join method will house the same logic you would have typically placed in your channel authorization Closure. Of course, you may also take advantage of channel model binding:

<?php

namespace App\Broadcasting;

use App\User;
use App\Order;

class OrderChannel
{
    /**
     * 新しいチャンネルインスタンスの生成
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * ユーザーのチャンネルへアクセスを認証
     *
     * @param  \App\User  $user
     * @param  \App\Order  $order
     * @return array|bool
     */
    public function join(User $user, Order $order)
    {
        return $user->id === $order->user_id;
    }
}

APIコントローラの生成API Controller Generation

APIにより使用されるリソースルートを定義する場合、createeditのようにHTMLテンプレートに存在するルートを通常除外します。これらのメソッドを含まないリソースコントローラを生成するには、make:controller実行時に--apiスイッチを使用できるようになりました。When declaring resource routes that will be consumed by APIs, you will commonly want to exclude routes that present HTML templates such as create and edit. To generate a resource controller that does not include these methods, you may now use the --api switch when executing the make:controller command:

php artisan make:controller API/PhotoController --api

モデルのシリアライズの向上Model Serialization Improvements

以前のLaravelリリースでは、キューされたモデルがロードしていたリレーションは、そのままリストアされませんでした。Laravel5.6では、キューされたモデルがロードしていたリレーションは、キューによりジョブが処理される際に自動的にリロードされます。In previous releases of Laravel, queued models would not be restored with their loaded relationships intact. In Laravel 5.6, relationships that were loaded on the model when it was queued are automatically re-loaded when the job is processed by the queue.

Eloquent日付キャストEloquent Date Casting

Eloquent日付キャストカラムのフォーマットを個別にカスタマイズできるようになりました。最初に、キャスト宣言の中で、希望する日付形式を指定します。一度指定すると、このフォーマットはモデルを配列やJSON西リアライズするとき、そのフォーマットが使用されます。You may now individually customize the format of Eloquent date cast columns. To get started, specify the desired date format within the cast declaration. Once specified, this format will be used when serializing the model to an array / JSON:

protected $casts = [
    'birthday' => 'date:Y-m-d',
    'joined_at' => 'datetime:Y-m-d H:00',
];

Bladeコンポーネント別名Blade Component Aliases

Bladeコンポーネントがサブディレクトリへ保存している場合、アクセスを簡単にするために別名が付けられるようになりました。たとえば、Bladeコンポーネントをresources/views/components/alert.blade.phpとして保存しているとイメージしてください。components.alertalertとして、このコンポーネントとして別名を付けるには、componentメソッドを使用します。If your Blade components are stored in a sub-directory, you may now alias them for easier access. For example, imagine a Blade component that is stored at resources/views/components/alert.blade.php. You may use the component method to alias the component from components.alert to alert:

Blade::component('components.alert', 'alert');

コンポーネントに別名を付けると、ディレクティブを使いレンダできます。Once the component has been aliased, you may render it using a directive:

@alert('alert', ['type' => 'danger'])
    You are not allowed to access this resource!
@endalert

追加のスロットがなければ、コンポーネントパラメータを省略できます。You may omit the component parameters if it has no additional slots:

@alert
    You are not allowed to access this resource!
@endalert

Argon2パスワードハッシュArgon2 Password Hashing

アプリケーションをバージョン7.2.0以降のPHP上で構築している場合、LaravelはArgon2アルゴリズムによるパスワードハッシュをサポートするようになりました。アプリケーションのデフォルトハッシュドライバーは、新しいconfig/hashing.php設定ファイルでコントロールします。If you are building an application on PHP 7.2.0 or greater, Laravel now supports password hashing via the Argon2 algorithm. The default hash driver for your application is controlled by a new config/hashing.php configuration file.

UUIDメソッドUUID Methods

Laravel5.6で新しいUUID生成メソッドが導入されました。Str::uuidStr::orderedUuidです。orderedUuidメソッドは、MySQLのようなデータベースにより、より簡単に、より効率的にインディックスされるタイムスタンプ先行のUUIDを生成します。これらのメソッドは、Ramsey\Uuid\Uuidオブジェクトを返します。Laravel 5.6 introduces two new methods for generating UUIDs: Str::uuid and Str::orderedUuid. The orderedUuid method will generate a timestamp first UUID that is more easily and efficiently indexed by databases such as MySQL. Each of these methods returns a Ramsey\Uuid\Uuid object:

use Illuminate\Support\Str;

return (string) Str::uuid();

return (string) Str::orderedUuid();

CollisionCollision

デフォルトのlaravel/laravelアプリケーションは、dev Composer依存パッケージとして、Nuno Maduro氏によりメンテナンスされているCollisionパッケージを含むようになりました。このパッケージは、コマンドラインのLaravelアプリケーションを操作する際、美しいエラーレポートを提供してくれます。The default laravel/laravel application now contains a dev Composer dependency for the Collision[https://github.com/nunomaduro/collision] package maintained by Nuno Maduro. This packages provides beautiful error reporting when interacting with your Laravel application on the command line:

Bootstrap 4Bootstrap 4

認証の定形コードやVueコンポーネント例のような、フロントエンドの全スカフォールドが、Bootstrap4へアップグレードされました。デフォルトとして生成するペジネーションリンクも、Bootstrap4になりました。All front-end scaffolding such as the authentication boilerplate and example Vue component have been upgraded to Bootstrap 4[https://blog.getbootstrap.com/2018/01/18/bootstrap-4/]. By default, pagination link generation also now defaults to Bootstrap 4.

章選択

公式パッケージ

設定

明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

テストコード表示
両コード表示
Pestのみ表示
PHPUnitのみ表示
和文変換

対象文字列と置換文字列を半角スペースで区切ってください。(最大5組各10文字まで)

本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作