Readouble

Laravel 7.x リリースノート

バージョニング規約Versioning Scheme

Laravelとファーストパーティパッケージは、セマンティックバージョニングにしたがっています。メジャーなフレームのリリースは、2月と8月の半年ごとにリリースされます。マイナーとパッチリリースはより細かく毎週リリースされます。マイナーとパッチリリースは、決してブレーキングチェンジを含みませんLaravel and its other first-party packages follow Semantic Versioning[https://semver.org]. Major framework releases are released every six months (~February and ~August), while minor and patch releases may be released as often as every week. Minor and patch releases should never contain breaking changes.

皆さんのアプリケーションやパッケージからLaravelフレームワークかコンポーネントを参照する場合は、Laravelのメジャーリリースはブレーキングチェンジを含まないわけですから、^7.0のようにバージョンを常に指定してください。しかし、新しいメジャーリリースへ1日以内でアップデートできるように、私たちは常に努力しています。When referencing the Laravel framework or its components from your application or package, you should always use a version constraint such as ^7.0, 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.

サポートポリシーSupport Policy

Laravel6のようなLTSリリースでは、バグフィックスは2年間、セキュリティフィックスは3年間提供します。これらのリリースは長期間に渡るサポートとメンテナンスを提供します。 一般的なリリースでは、バグフィックスは6ヶ月、セキュリティフィックスは1年です。Lumenのようなその他の追加ライブラリでは、最新リリースのみでバグフィックスを受け付けています。また、Laravelがサポートするデータベースのサポートについても確認してください。For LTS releases, such as Laravel 6, 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. For all additional libraries, including Lumen, only the latest release receives bug fixes. In addition, please review the database versions supported by Laravel[/docs/{{version}}/database#introduction].

バージョンVersion リリースRelease バグフィックス期限Bug Fixes Until セキュリティフィックス期限Security Fixes Until
6 (LTS)6 (LTS) 2019年9月3日September 3rd, 2019 2021年9月3日September 3rd, 2021 2022年9月3日September 3rd, 2022
77 2020年3月3日March 3rd, 2020 2020年9月10日September 10th, 2020 2021年3月3日March 3rd, 2021
88 2020年9月8日September 8th, 2020 2021年3月8日March 8th, 2021 2021年9月8日September 8th, 2021

Laravel 7Laravel 7

Laravel7は、Laravel6.xで行われた向上に加え、以降の変更で構成されています。Laravel Sanctumの導入、ルーティングスピードの向上、カスタムEloquentキャスト、Bladeコンポーネントタグ、Fluentな文字列操作、開発者に焦点を当てたHTTPクライアント、ファーストパーティCORSサポート、ルートモデル結合の制約の向上、スタブのカスタマイズ、ならびに多くのバグフィックスとユーザービリティの向上ですLaravel 7 continues the improvements made in Laravel 6.x by introducing Laravel Sanctum, routing speed improvements, custom Eloquent casts, Blade component tags, fluent string operations, a developer focused HTTP client, first-party CORS support, improved scoping for route model binding, stub customization, database queue improvements, multiple mail drivers, query-time casts, a new artisan test command, and a variety of other bug fixes and usability improvements.

Laravel SanctumLaravel Sanctum

Laravel SanctumはTaylor Otwellにより構築されました。Laravel Sanctum was built by Taylor Otwell[https://github.com/taylorotwell].

Laravel Sanctum(サンクタム:聖所)はSPA(Single Page Applications)のための、シンプルでトークンベースのAPIを使った羽のように軽い認証システムです。Sanctumはアプリケーションのユーザーのアカウントごとに、複数のAPIトークンを生成できます。これらのトークンには、実行可能なアクションを限定するアビリティ・スコープを与えられます。Laravel Sanctum provides a featherweight authentication system for SPAs (single page applications), mobile applications, and simple, token based APIs. Sanctum allows each user of your application to generate multiple API tokens for their account. These tokens may be granted abilities / scopes which specify which actions the tokens are allowed to perform.

Laravel Sanctumの詳細は、Sanctumのドキュメントで確認してください。For more information on Laravel Sanctum, consult the Sanctum documentation[/docs/{{version}}/sanctum].

カスタムEloquentキャストCustom Eloquent Casts

カスタムEloquentキャストはTaylor Otwellにより構築されました。Custom Eloquent casts was contributed by Taylor Otwell[https://github.com/taylorotwell].

Laravelには多様な利便性のあるキャストタイプが用意されています。しかし、自分自身でキャストタイプを定義する必要が起きることもまれにあります。これを行うには、CastsAttributesインターフェイスを実装したクラスを定義してください。Laravel has a variety of built-in, helpful cast types; however, you may occasionally need to define your own cast types. You may now accomplish this by defining a class that implements the CastsAttributes interface.

このインターフェイスを実装するクラスでは、getsetメソッドを定義します。getメソッドはデータベースにある元の値をキャストした値へ変換することに責任を持ちます。一方のsetメソッドはキャストされている値をデータベースに保存できる元の値に変換します。例として、組み込み済みのjsonキャストタイプをカスタムキャストタイプとして再実装してみましょう。Classes that implement this interface must define a get and set methods. The get method is responsible for transforming a raw value from the database into a cast value, while the set method should transform a cast value into a raw value that can be stored in the database. As an example, we will re-implement the built-in json cast type as a custom cast type:

<?php

namespace App\Casts;

use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class Json implements CastsAttributes
{
    /**
     * 指定された値をキャストする
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  mixed  $value
     * @param  array  $attributes
     * @return array
     */
    public function get($model, $key, $value, $attributes)
    {
        return json_decode($value, true);
    }

    /**
     * 指定された値を保存用に準備
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  array  $value
     * @param  array  $attributes
     * @return string
     */
    public function set($model, $key, $value, $attributes)
    {
        return json_encode($value);
    }
}

カスタムキャストタイプが定義できたら、クラス名を使いモデル属性へ指定します。Once you have defined a custom cast type, you may attach it to a model attribute using its class name:

<?php

namespace App;

use App\Casts\Json;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * ネイティブなタイプへキャストする属性
     *
     * @var array
     */
    protected $casts = [
        'options' => Json::class,
    ];
}

カスタムEloquentキャストの書き方は、Eloquentドキュメントで調べてください。To learn how to write custom Eloquent casts, including custom casts that cast to value objects, please consult the Eloquent documentation[/docs/{{version}}/eloquent-mutators#custom-casts].

Bladeコンポーネントタグと向上Blade Component Tags & Improvements

BladeコンポーネントタグはSpatieMarcel PociotCaleb PorzioDries VintsTaylor Otwellから貢献を受けました。Blade component tags were contributed by Spatie[https://spatie.be/], Marcel Pociot[https://twitter.com/marcelpociot], Caleb Porzio[https://twitter.com/calebporzio], Dries Vints[https://twitter.com/driesvints], and Taylor Otwell[https://github.com/taylorotwell].

lightbulb">Tip!! Bladeコンポーネントはタグベースのレンダリング、属性管理、コンポーネントクラス、インラインビューコンポーネントなどを実現するためにオーバーホールされました。Bladeコンポーネントのオーバーホールは広範囲に及んでいるため、この機能を学ぶためにBladeコンポーネント全体を確認してください。{tip} Blade components have been overhauled to allow tag based rendering, attribute management, component classes, inline view components, and more. Since the overhaul of Blade components is so extensive, please consult the full Blade component documentation[/docs/{{version}}/blade#components] to learn about this feature.

要約すれば、コンポーネントは、受け取るデータを指定する関連付けしたクラスが持てるようになりました。コンポーネントクラス上にあるパブリックのプロパティとメソッドはすべて自動的にコンポーネントビューで利用できます。コンポーネント上で指定された、追加のHTML属性は属性バッグインスタンスである$attributes変数で自動的に管理できます。In summary, a component may now have an associated class which specifies the data it accepts. All public properties and methods defined on the component class will automatically be made available to the component view. Any additional HTML attributes specified on the component may be managed using the automatically included $attributes variable, which is an attribute bag instance.

たとえば、App\View\Components\Alertコンポーネントが定義されていると仮定しましょう。In this example, we will assume that an App\View\Components\Alert component has been defined like so:

<?php

namespace App\View\Components;

use Illuminate\View\Component;

class Alert extends Component
{
    /**
     * alertタイプ
     *
     * @var string
     */
    public $type;

    /**
     * コンポーネントインスタンスの生成
     *
     * @param  string  $type
     * @return void
     */
    public function __construct($type)
    {
        $this->type = $type;
    }

    /**
     * 指定されたalertタイプに対するクラスを取得
     *
     * @return string
     */
    public function classForType()
    {
        return $this->type == 'danger' ? 'alert-danger' : 'alert-warning';
    }

    /**
     * コンポーネントを表すビュー/コンテンツを取得
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        return view('components.alert');
    }
}

そして、関連するコンポーネントBladeテンプレートを以下のように定義してあるとしましょう。And, assuming the component's Blade template has been defined like so:

<!-- /resources/views/components/alert.blade.php -->

<div class="alert {{ $classForType }}" {{ $attributes }}>
    {{ $heading }}

    {{ $slot }}
</div>

このコンポーネントは他のBladeビューでコンポーネントタグを使用し、レンダーされるでしょう。The component may be rendered in another Blade view using the component's tag:

<x-alert type="error" class="mb-4">
    <x-slot name="heading">
        Alertコンテント…
    </x-slot>

    デフォルトスロットの内容…
</x-alert>

紹介したのはLaravel7で行ったBladeコンポーネントのオーバーホールの小さなサンプルであり、無名コンポーネント、インラインビューコンポーネントや他の数々の機能はデモンストレートしていません。この機能を学ぶには、どうぞBladeコンポーネントの完全なドキュメントを調べてください。As mentioned, this is just a very small sample of the functionality of the Blade component overhaul in Laravel 7 and does not demonstrate anonymous components, inline view components, and a variety of other features. Please consult the full Blade component documentation[/docs/{{version}}/blade#components] to learn about this feature.

Note: note 以前の@component Bladeコンポーネント記法は残っていますし、削除予定もありません。{note} The previous @component syntax for Blade components has not and will not be removed.

HTTPクライアントHTTP Client

HTTPクライアントはGuzzleのラッパーであり、Adam WathanJason McCrearyTaylor Otwellから貢献を受けました。The HTTP client is a wrapper of Guzzle and was contributed by Adam Wathan[https://twitter.com/adamwathan], Jason McCreary[https://twitter.com/gonedark], and Taylor Otwell[https://github.com/taylorotwell].

他のWebアプリケーションと連携を取る、送信HTTPリクエストを簡単に作成できるよう、Laravelは小さくて読み書きしやすいGuzzle HTTPクライアントのAPIを提供しています。LaravelのGuzzleラッパーはもっとも繁用されるユースケースと開発者が素晴らしい体験をできることに重点を置いています。例として、クライアントでJSONデータを送るPOSTを簡単に作ってみましょう。Laravel now provides an expressive, minimal API around the Guzzle HTTP client[http://docs.guzzlephp.org/en/stable/], allowing you to quickly make outgoing HTTP requests to communicate with other web applications. Laravel's wrapper around Guzzle is focused on its most common use cases and a wonderful developer experience. For example, the client makes it a breeze to POST and interface with JSON data:

use Illuminate\Support\Facades\Http;

$response = Http::withHeaders([
    'X-First' => 'foo',
    'X-Second' => 'bar'
])->post('http://test.com/users', [
    'name' => 'Taylor',
]);

return $response['id'];

さらに、このHTTPクライアントは豊富な素晴らしいテスト機能を備えています。In addition, the HTTP client provides fantastic, ergonomic testing functionality:

Http::fake([
    // GitHubエンドポイントに対するJSONレスポンスをスタブ
    'github.com/*' => Http::response(['foo' => 'bar'], 200, ['Headers']),

    // Googleエンドポイントに対する文字列レスポンスをスタブ
    'google.com/*' => Http::response('Hello World', 200, ['Headers']),

    // GitHubエンドポイントに対して一連のレスポンスをスタブ
    'facebook.com/*' => Http::sequence()
                            ->push('Hello World', 200)
                            ->push(['foo' => 'bar'], 200)
                            ->pushStatus(404),
]);

HTTPクライアントの機能すべてについて学習するには、HTTPクライアントドキュメントを調べてください。To learn more about all of the features of the HTTP client, please consult the HTTP client documentation[/docs/{{version}}/http-client].

Fluent文字列操作Fluent String Operations

Fluent文字列操作は、Taylor Otwellから貢献を受けました。Fluent string operations were contributed by Taylor Otwell[https://twitter.com/taylorotwell].

LaravelにもともとあるIlluminate\Support\Strクラスには皆さん慣れているでしょう。役に立つ、さまざまな文字列操作機能を提供しています。Laravel7ではよりオブジェクト指向で読み書きしやすい(Fluent)文字列操作ライブラリをこうした機能上に構築しました。FluentなIlluminate\Support\Stringableオブジェクトは、Str::ofメソッドで生成できます。数多くのメソッドを文字列操作のためにオブジェクトへチェーン可能です。You are likely familiar with Laravel's existing Illuminate\Support\Str class, which provides a variety of helpful string manipulation functions. Laravel 7 now offers a more object-oriented, fluent string manipulation library built on top of these functions. You may create a fluent Illuminate\Support\Stringable object using the Str::of method. A variety of methods may then be chained onto the object to manipulate the string:

return (string) Str::of('  Laravel Framework 6.x ')
                    ->trim()
                    ->replace('6.x', '7.x')
                    ->slug();

Fluentな文字列操作により使用できるメソッドの情報は、ドキュメント全体をお読みください。For more information on the methods available via fluent string manipulation, please consult its full documentation[/docs/{{version}}/helpers#fluent-strings].

ルートモデル結合の向上Route Model Binding Improvements

ルートモデル結合の向上は、Taylor Otwellから貢献を受けました。Route model binding improvements were contributed by Taylor Otwell[https://twitter.com/taylorotwell].

キーのカスタマイズKey Customization

ときにid以外のカラムを使いEloquentモデルを解決したい場合もあります。そのためLaravel7ではルートパラメータ定義の中でカラムを指定できるようにしました。Sometimes you may wish to resolve Eloquent models using a column other than id. To do so, Laravel 7 allows you to specify the column in the route parameter definition:

Route::get('api/posts/{post:slug}', function (App\Post $post) {
    return $post;
});

自動制約Automatic Scoping

一つの定義中に複数のEloquentモデルを暗黙的に結合し、2つ目のEloquentモデルが最初のEloquentモデルの子である必要がある場合などでは、その2つ目のモデルを取得したいと思うでしょう。例として、特定のユーザーのブログポストをスラグで取得する場合を想像してください。Sometimes, when implicitly binding multiple Eloquent models in a single route definition, you may wish to scope the second Eloquent model such that it must be a child of the first Eloquent model. For example, consider this situation that retrieves a blog post by slug for a specific user:

use App\Post;
use App\User;

Route::get('api/users/{user}/posts/{post:slug}', function (User $user, Post $post) {
    return $post;
});

カスタムなキーを付けた暗黙の結合をネストしたルートパラメータで使用するとき、親で定義されるリレーションは慣習にしたがい名付けられているだろうとLaravel7は推測し、ネストしたモデルへのクエリを自動的に制約します。この場合、UserモデルにはPostモデルを取得するためにposts(ルートパラメータ名の複数形)という名前のリレーションがあると想定します。When using a custom keyed implicit binding as a nested route parameter, Laravel 7 will automatically scope the query to retrieve the nested model by its parent using conventions to guess the relationship name on the parent. In this case, it will be assumed that the User model has a relationship named posts (the plural of the route parameter name) which can be used to retrieve the Post model.

ルートモデル結合の詳細情報は、ルートのドキュメントをご覧ください。For more information on route model binding, please consult the routing documentation[/docs/{{version}}/routing#route-model-binding].

複数メールドライバMultiple Mail Drivers

複数メールドライバのサポートは、Taylor Otwellから貢献を受けました。Multiple mail driver support was contributed by Taylor Otwell[https://twitter.com/taylorotwell].

Laravel7では1つのアプリケーションで複数の「メーラー」を設定できるようになりました。各メーラーはこのファイルの中でオプションや、独自の「トランスポート」でさえも設定しています。これにより、アプリケーションが特定のメッセージを送るため、異なったメールサービスを利用できるようになっています。たとえばアプリケーションで業務メールはPostmarkを使い、一方でバルクメールはAmazon SESと使い分けることができます。Laravel 7 allows the configuration of multiple "mailers" for a single application. Each mailer configured within the mail configuration file may have its own options and even its own unique "transport", allowing your application to use different email services to send certain email messages. For example, your application might use Postmark to send transactional mail while using Amazon SES to send bulk mail.

Laravelはmail設定ファイルのdefaultメーラーとして設定されているメーラーをデフォルトで使用します。しかし、特定のメール設定を使用してメッセージを遅るためにmailerメソッドが使用できます。By default, Laravel will use the mailer configured as the default mailer in your mail configuration file. However, you may use the mailer method to send a message using a specific mailer configuration:

Mail::mailer('postmark')
        ->to($request->user())
        ->send(new OrderShipped($order));

ルートキャッシュスピードの向上Route Caching Speed Improvements

ルートキャッシュスピードの向上はアップストリームのSymfony貢献者達とDries Vintsから貢献を受けました。The route caching speed improvements were contributed by upstream Symfony[https://symfony.com] contributors and Dries Vints[https://twitter.com/driesvints].

Laravel7にはマッチングコンパイラの新しいメソッドや、route:cache Artisanコマンドによるルートのキャッシュが含まれています。大きなアプリケーション(たとえば800以上のルートを持つアプリケーション)においてシンプルな"Hello World"ベンチマークでは、2倍のスピード向上という結果が出せます。アプリケーションに特別な変更は必要ありません。Laravel 7 includes a new method of matching compiled, cached routes that have been cached using the route:cache Artisan command. On large applications (for example, applications with 800 or more routes), these improvements can result in a 2x speed improvement in requests per second on a simple "Hello World" benchmark. No changes to your application are required.

CORSサポートCORS Support

CORSのサポートはBarry vd. Heuvelから貢献を受けました。CORS support was contributed by Barry vd. Heuvel[https://twitter.com/barryvdh].

Laravel7では、Barry vd. Heuvelが書いた人気のLaravel CORSパッケージを統合し、Cross-Origin Resource Sharing (CORS) OPTIONSリクエストに対するファーストパーティサポートを提供しています。新しいcors設定はデフォルトLaravelアプリケーションスケルトンに含まれています。Laravel 7 includes first-party support for configuring Cross-Origin Resource Sharing (CORS) OPTIONS request responses by integrating the popular Laravel CORS package written by Barry vd. Heuvel. A new cors configuration is included in the default Laravel application skeleton[https://github.com/laravel/laravel/blob/develop/config/cors.php].

Laravel7.xにおけるCORSサポートの詳細は、CORSのドキュメントを調べてください。For more information on CORS support in Laravel 7.x, please consult the CORS documentation[/docs/{{version}}/routing#cors].

クエリ時間キャストQuery Time Casts

クエリ時間キャストはMatt Barlowから貢献を受けました。Query time casting was contributed by Matt Barlow[https://github.com/mpbarlow].

テーブルから元の値でセレクトするときのように、クエリ実行時にキャストを適用する必要が稀に起きます。例として以下のクエリを考えてください。Sometimes you may need to apply casts while executing a query, such as when selecting a raw value from a table. For example, consider the following query:

use App\Post;
use App\User;

$users = User::select([
    'users.*',
    'last_posted_at' => Post::selectRaw('MAX(created_at)')
            ->whereColumn('user_id', 'users.id')
])->get();

テーブルから元の値でセレクトするときのように、クエリ実行時にキャストを適用する必要が稀に起きます。例として以下のクエリを考えてください。これを行うにはLaravel7で提供しているwithCastsメソッドを使ってください。The last_posted_at attribute on the results of this query will be a raw string. It would be convenient if we could apply a date cast to this attribute when executing the query. To accomplish this, we may use the withCasts method provided by Laravel 7:

$users = User::select([
    'users.*',
    'last_posted_at' => Post::selectRaw('MAX(created_at)')
            ->whereColumn('user_id', 'users.id')
])->withCasts([
    'last_posted_at' => 'date'
])->get();

MySQL8以上でのデータベースキューの向上MySQL 8 Database Queue Improvements

MySQLデータベースキューの向上はMohamed Saidから貢献を受けました。MySQL database queue improvements were contributed by Mohamed Said[https://github.com/themsaid].

Laravelの以前のリリースでは、databaseキューは実機環境での使用に対して十分堅牢に考えられていないため、デッドロックを起こしていました。しかしながら、Laravel7ではMySQL8以上で裏打ちされたキューにより、このデータベースを使用したアプリケーションで改善されました。FOR UPDATE SKIP LOCKED節とその他のSQLの改善を利用し、高ボリュームの実働アプリケーションでもdatabaseドライバーは安全に使えるようになりました。In previous releases of Laravel, the database queue was not considered robust enough for production usage, due to deadlocks. However, Laravel 7 provides improvements to applications using MySQL 8 as their database backed queue. By using the FOR UPDATE SKIP LOCKED clause and other SQL enhancements, the database driver may now safely be used in higher volume production applications.

Artisan testコマンドArtisan test Command

testコマンドは、Nuno Maduroから貢献を受けました。The test command was contributed by Nuno Maduro[https://twitter.com/enunomaduro].

テスト実行ではphpunitコマンドに加え、test Artisanコマンドも使用できます。Artisanテストランナーは美しいコンソールUXと現在実行中のテストに関するより詳しい情報を提供します。さらにテストに失敗した最初の時点で自動的に停止します。In addition to the phpunit command, you may now use the test Artisan command to run your tests. The Artisan test runner provides beautiful console UX and more information regarding the test that is currently running. In addition, the runner will automatically stop on the first test failure:

php artisan test

phpunitコマンドで使用できる引数はすべてArtisan testコマンドにも渡せます。Any arguments that can be passed to the phpunit command may also be passed to the Artisan test command:

php artisan test --group=feature

Markdownメールテンプレートの向上Markdown Mail Template Improvements

Markdownメールテンプレートの向上はTaylor Otwellから貢献を受けました。Markdown mail template improvements were contributed by Taylor Otwell[https://twitter.com/taylorotwell].

デフォルトMarkdownメールテンプレートはTailwind CSSカラーパレットを基盤としたよりモダンなデザインに一新されました。もちろん、このテンプレートはリソース公開し、アプリケーションのニーズに合わせてカスタマイズできます。The default Markdown mail template has received a fresh, more modern design based on the Tailwind CSS color palette. Of course, this template can be published and customized according to your application's needs:

Markdownメールのより詳しい情報は、メールドキュメントをご覧ください。For more information on Markdown mail, please consult the mail documentation[/docs/{{version}}/mail#markdown-mailables].

スタブのカスタマイズStub Customization

StubのカスタマイズはTaylor Otwellから貢献を受けました。Stub customization was contributed by Taylor Otwell[https://twitter.com/taylorotwell].

Artisanコンソールのmakeコマンドは、コントローラ、マイグレーション、テストのような数多くのクラスを生成するために使われます。これらのクラスは皆さんの入力を元にして、「スタブ」ファイルへ値を埋め込み生成されます。場合により、Aritsanが生成するファイルを少し変更したい場合もあるでしょう。このためLaravel7はstub:publishコマンドで、カスタマイズのためにもっとも一般的なスタブをリソース公開できるようになりました。The Artisan console's make commands are used to create a variety of classes, such as controllers, jobs, migrations, and tests. These classes are generated using "stub" files that are populated with values based on your input. However, you may sometimes wish to make small changes to files generated by Artisan. To accomplish this, Laravel 7 provides the stub:publish command to publish the most common stubs for customization:

php artisan stub:publish

リソース公開されたスタブはアプリケーションのルート下のstubsディレクトリの中に保存されます。そうしたスタブに加えた変更は、名前に対応するArtisan makeコマンドを使用して生成するときに反映されます。The published stubs will be located within a stubs directory in the root of your application. Any changes you make to these stubs will be reflected when you generate their corresponding classes using Artisan make commands.

キューのmaxExceptions設定Queue maxExceptions Configuration

maxExceptionsプロパティはMohamed Saidから貢献を受けました。The maxExceptions property was contributed by Mohamed Said[https://twitter.com/themsaid].

ジョブを何度も再試行するように指定している場合、指定した回数の例外が発生したことをきっかけにしてその再試行を失敗として取り扱いたい場合も起きると思います。Laravel7では、ジョブクラスにmaxExceptionsプロパティを定義してください。Sometimes you may wish to specify that a job may be attempted many times, but should fail if the retries are triggered by a given number of exceptions. In Laravel 7, you may define a maxExceptions property on your job class:

<?php

namespace App\Jobs;

class ProcessPodcast implements ShouldQueue
{
    /**
     * 最大試行回数
     *
     * @var int
     */
    public $tries = 25;

    /**
     * 失敗と判定するまで許す最大例外数
     *
     * @var int
     */
    public $maxExceptions = 3;

    /**
     * ジョブの実行
     *
     * @return void
     */
    public function handle()
    {
        Redis::throttle('key')->allow(10)->every(60)->then(function () {
            // ロックが取得でき、ポッドキャストの処理を行う…
        }, function () {
            // ロックが取得できなかった…場合の処理を行う…
            return $this->release(10);
        });
    }
}

この例の場合、アプリケーションがRedisのロックを取得できない場合は、そのジョブは10秒でリリースされます。そして、25回再試行を継続します。しかし発生した例外を3回処理しなかった場合、ジョブは失敗します。In this example, the job is released for ten seconds if the application is unable to obtain a Redis lock and will continue to be retried up to 25 times. However, the job will fail if three unhandled exceptions are thrown by the job.

章選択

設定

明暗テーマ
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に保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作