Readouble

Laravel 5.8 アップグレードガイド

重要度の高い変更High Impact Changes

- [キャッシュ持続時間が秒指定に](#cache-ttl-in-seconds) - [キャッシュロックの安全性向上](#cache-lock-safety-improvements) - [環境変数のパース](#environment-variable-parsing) - [Markdownファイルのディレクトリ変更](#markdown-file-directory-change) - [Nexmo/Slack通知チャンネル](#nexmo-slack-notification-channels) - [新しいデフォルトパスワード長](#new-default-password-length)

重要度が中程度の変更Medium Impact Changes

- [コンテナジェネレーターとタグ付けサービス](#container-generators) - [SQLiteバージョン制約](#sqlite) - [ヘルパから文字列と配列クラスへ](#string-and-array-helpers) - [遅延サービスプロバイダ](#deferred-service-providers) - [PSR-16準拠](#psr-16-conformity) - [不規則変化する複数形のモデル名](#model-names-ending-with-irregular-plurals) - [IDが増加するカスタムピボットモデル](#custom-pivot-models-with-incrementing-ids) - [Pheanstalk4.0](#pheanstalk-4)

5.7から5.8.0へのアップグレードUpgrading To 5.8.0 From 5.7

アップグレードの見積もり時間:1時間Estimated Upgrade Time: 1 Hour

Note: note 私達は、互換性を失う可能性がある変更を全部ドキュメントにしようとしています。しかし、変更点のいくつかは、フレームワークの明確ではない部分で行われているため、一部の変更が実際にアプリケーションに影響を与えてしまう可能性があります。{note} We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application.

依存パッケージのアップデートUpdating Dependencies

composer.jsonファイル中のlaravel/frameworkパッケージのバージョンを5.8.*にアップデートしてください。Update your laravel/framework dependency to 5.8.* in your composer.json file.

次に、アプリケーションで使用している3rdパーティーパッケージを調査し、Laravel5.8をサポートしているバージョンを使用していることを確認してください。Next, examine any 3rd party packages consumed by your application and verify you are using the proper version for Laravel 5.8 support.

Application契約The Application Contract

environmentメソッドThe environment Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Contracts\Foundation\Application契約で利用法が規定されているenvironmentメソッドは変更されました。アプリケーションでこの契約を実装している場合は、メソッドの使用法を更新してください。The environment method signature of the Illuminate\Contracts\Foundation\Application contract has changed[https://github.com/laravel/framework/pull/26296]. If you are implementing this contract in your application, you should update the method signature:

/**
 * アプリケーション環境の取得もしくは判定
 *
 * @param  string|array  $environments
 * @return string|bool
 */
public function environment(...$environments);

メソッド追加Added Methods

影響の可能性: とても低いLikelihood Of Impact: Very Low

bootstrapPathconfigPathdatabasePathenvironmentPathresourcePathstoragePathresolveProviderbootstrapWithconfigurationIsCacheddetectEnvironmentenvironmentFileenvironmentFilePathgetCachedConfigPathgetCachedRoutesPathgetLocalegetNamespacegetProvidershasBeenBootstrappedloadDeferredProvidersloadEnvironmentFromroutesAreCachedsetLocaleshouldSkipMiddlewareterminateメソッドがIlluminate\Contracts\Foundation\Application契約に追加されましたThe bootstrapPath, configPath, databasePath, environmentPath, resourcePath, storagePath, resolveProvider, bootstrapWith, configurationIsCached, detectEnvironment, environmentFile, environmentFilePath, getCachedConfigPath, getCachedRoutesPath, getLocale, getNamespace, getProviders, hasBeenBootstrapped, loadDeferredProviders, loadEnvironmentFrom, routesAreCached, setLocale, shouldSkipMiddleware and terminate methods were added to the Illuminate\Contracts\Foundation\Application contract[https://github.com/laravel/framework/pull/26477].

このインターフェイスを実装している可能性はとても低いと思われますが、実装している場合はこれらのメソッドを追加してください。In the very unlikely event you are implementing this interface, you should add these methods to your implementation.

認証Authentication

パスワードリセット通知ルートパラメータPassword Reset Notification Route Parameter

影響の可能性: 低いLikelihood Of Impact: Low

ユーザーがパスワードをリセットするためのリンクを必要とする場合、Laravelはpasswrod.reset名前付きルートに対するURLをrouteヘルパを利用し生成します。Laravel5.7使用時、明確な名前無しにrouteヘルパへトークンを渡してしました。When a user requests a link to reset their password, Laravel generates the URL using the route helper to create a URL to the password.reset named route. When using Laravel 5.7, the token is passed to the route helper without an explicit name, like so:

route('password.reset', $token);

Laravel5.8を使用する場合は、明確なパラメータとしてrouteヘルパへトークンを渡します。When using Laravel 5.8, the token is passed to the route helper as an explicit parameter:

route('password.reset', ['token' => $token]);

そのため、独自のpassword.resetルートを定義している場合、{token}パラメータを確実にURIへ含めてください。Therefore, if you are defining your own password.reset route, you should ensure that it contains a {token} parameter in its URI.

新しいデフォルトパスワード長New Default Password Length

影響の可能性: 高いLikelihood Of Impact: High

パスワードの選択とリセット時に要求されるパスワード長が、8文字へ変更されました。この新しい8文字長のデフォルトに合うように、アプリケーション中のバリデーションルールやロジックを変更してください。The required password length when choosing or resetting a password was changed to eight characters[https://github.com/laravel/framework/pull/25957]. You should update any validation rules or logic within your application to match this new eight character default.

以前の6文字長を保持する、もしくは他の長さへ変更する必要がある場合は、Illuminate\Auth\Passwords\PasswordBrokerクラスを拡張し、validatePasswordWithDefaultsメソッドをオーバーライドし、カスタムロジックを組み込んでください。If you need to preserve the previous six character length or a different length, you may extend the Illuminate\Auth\Passwords\PasswordBroker class and overwrite the validatePasswordWithDefaults method with custom logic.

キャッシュCache

持続時間が秒指定にTTL in seconds

影響の可能性: とても高いLikelihood Of Impact: Very High

より細かい時間でアイテムの保存時間を扱えるように、キャッシュの保存時間は分から秒単位になりました。Illuminate\Cache\Repositoryクラスとこれを拡張したクラスのputputManyaddremembersetDefaultCacheTimeメソッド、並びに各キャッシュ保存のputメソッドはこの動作変更へ更新されました。詳細は、関係するPRをご覧ください。In order to allow a more granular expiration time when storing items, the cache item time-to-live has changed from minutes to seconds. The put, putMany, add, remember and setDefaultCacheTime methods of the Illuminate\Cache\Repository class and its extended classes, as well as the put method of each cache store were updated with this changed behavior. See the related PR[https://github.com/laravel/framework/pull/27276] for more info.

前述のメソッドに整数値を渡している場合、キャッシュにアイテムを残したい時間が秒数になったことに留意し、コードを変更してください。言い換えれば、アイテムの期限がいつ切れるかを表すDateTimeインスタンスを渡したほうが良いでしょう。If you are passing an integer to any of these methods, you should update your code to ensure you are now passing the number of seconds you wish the item to remain in the cache. Alternatively, you may pass a DateTime instance indicating when the item should expire:

// Laravel5.7:30分アイテムは保存される
Cache::put('foo', 'bar', 30);

// Laravel5.8:30秒アイテムは保存される
Cache::put('foo', 'bar', 30);

// Laravel5.7と5.8:30秒アイテムは保存される
Cache::put('foo', 'bar', now()->addSeconds(30));

lightbulb">Tip!! この変更により、Laravelキャッシュシステムは、PSR-16キャッシュライブラリ基準に完全に準拠しました。{tip} This change makes the Laravel cache system fully compliant with the PSR-16 caching library standard[https://www.php-fig.org/psr/psr-16/].

PSR-16準拠PSR-16 Conformity

影響の可能性: 中程度Likelihood Of Impact: Medium

前記により返却値が変更されたことに付け加え、Illuminate\Cache\RepositoryクラスのputputManyaddメソッドのTTL引数もPSR-16基準をより準拠するように変更しました。デフォルトはnullで、TTLを指定しない呼び出しの新しい振る舞いは、キャッシュアイテムを永久に保存することになりました。さらに、TTLが0か負数の場合はキャッシュから削除されます。詳細は、関連するPRをご覧ください。In addition to the return value changes from below[#the-repository-and-store-contracts], the TTL argument of the put, putMany and add method's of the Illuminate\Cache\Repository class was updated to conform better with the PSR-16 spec. The new behavior provides a default of null so a call without specifying a TTL will result in storing the cache item forever. Additionally, storing cache items with a TTL of 0 or lower will remove items from the cache. See the related PR[https://github.com/laravel/framework/pull/27217] for more info.

KeyWrittenイベントもこの変更により、更新されましたThe KeyWritten event was also updated[https://github.com/laravel/framework/pull/27265] with these changes.

ロックの安全性向上Lock Safety Improvements

影響の可能性: 高いLikelihood Of Impact: High

バージョン5.7以前のLaravelでは、いくつかのキャッシュドライバで提供されていた「アトミックロック」機能は予測しない動作を引き起こす可能性がありました。In Laravel 5.7 and prior versions of Laravel, the "atomic lock" feature provided by some cache drivers could have unexpected behavior leading to the early release of locks.

たとえば、クライアントAが10秒間有効なfooロックを獲得します。クライアントAがタスクを終了するまで実際には20秒かかるとします。クライアントAの処理中に、10秒立つとキャッシシステムのロックが自動的に解除されます。クライアントBfooロックを獲得します。クライアントAがタスクを終了し、fooロックを解除すると、思いがけずクライアントBが獲得しているロックを解除してしまいます。クライアントCは、そのロックを獲得できるようになってしまいます。For example: Client A acquires lock foo with a 10 second expiration. Client A actually takes 20 seconds to finish its task. The lock is released automatically by the cache system 10 seconds into Client A's processing time. Client B acquires lock foo. Client A finally finishes its task and releases lock foo, inadvertently releasing Client B's hold on the lock. Client C is now able to acquire the lock.

このシナリオを避けるに、通常の環境ではロックの所有者のみがリリースできることをフレームワークが確実に行えるようにするために、「スコープトークン」を埋め込んだロックが生成されるようになりました。In order to mitigate this scenario, locks are now generated with an embedded "scope token" which allows the framework to ensure that, under normal circumstances, only the proper owner of a lock can release a lock.

ロック操作にCache::lock()->get(Closure)メソッドを使用している場合、変更は必要ありません。If you are using the Cache::lock()->get(Closure) method of interacting with locks, no changes are required:

Cache::lock('foo', 10)->get(function () {
    // ロックは自動的に安全な開放を行う
});

しかし、みなさんが自分でCache::lock()->release()を呼び出している場合、ロックのインスタンスを保持するようにコードを変更する必要があります。そのため、タスクを実行し終えた後、同じロックインスタンスreleaseメソッドを呼び出してください。However, if you are manually calling Cache::lock()->release(), you must update your code to maintain an instance of the lock. Then, after you are done performing your task, you may call the release method on the same lock instance. For example:

if (($lock = Cache::lock('foo', 10))->get()) {
    // タスクの実行…

    $lock->release();
}

ときに、ロックをあるプロセスで獲得し、別のプロセスで開放したい場合があります。たとえば、Webリクエストでロックを獲得し、そのリクエストから起動したキュー済みジョブの最後で、ロックを開放したい場合です。そのようなシナリオでは、ジョブで渡されたトークンを使い、ロックを再インスタンス化できるように、ロックを限定する「所有者(owner)のトークン」をキューするジョブへ渡す必要があります。Sometimes, you may wish to acquire a lock in one process and release it in another process. For example, you may acquire a lock during a web request and wish to release the lock at the end of a queued job that is triggered by that request. In this scenario, you should pass the lock's scoped "owner token" to the queued job so that the job can re-instantiate the lock using the given token:

// コントローラ側
$podcast = Podcast::find(1);

if (($lock = Cache::lock('foo', 120))->get()) {
    ProcessPodcast::dispatch($podcast, $lock->owner());
}

// ProcessPodcastジョブ側
Cache::restoreLock('foo', $this->owner)->release();

現在の所有者にかかわらず、ロックを開放したい場合は、forceReleaseメソッドを使用します。If you would like to release a lock without respecting its current owner, you may use the forceRelease method:

Cache::lock('foo')->forceRelease();

RepositoryStore契約The Repository and Store Contracts

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Contracts\Cache\Repository契約のputforeverメソッド、およびIlluminate\Contracts\Cache\Store契約のputputManyforeverメソッドの返却値をPSR-16へ完全に準拠させるため、voidからbool変更されましたIn order to be fully compliant with PSR-16 the return values of the put and forever methods of the Illuminate\Contracts\Cache\Repository contract and the return values of the put, putMany and forever methods of the Illuminate\Contracts\Cache\Store contract have been changed[https://github.com/laravel/framework/pull/26726] from void to bool.

コレクションCollections

addメソッドThe add Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

addメソッドは、Eloquentのコレクションクラスから、ベースコレクションクラスへ移動しましたIlluminate\Support\Collectionを拡張し、拡張したクラスにaddメソッドがある場合は、メソッドの用法が親クラスと一致するようにしてください。The add method has been moved[https://github.com/laravel/framework/pull/27082] from the Eloquent collection class to the base collection class. If you are extending Illuminate\Support\Collection and your extended class has an add method, make sure the method signature matches its parent:

public function add($item);

firstWhereメソッドThe firstWhere Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

whereメソッドの使用法と合わせるために、firstWhereメソッドの使用法が変更されました。このメソッドをオーバーライドしている場合は、メソッドの使用方法を親クラスと合わせてください。The firstWhere method signature has changed[https://github.com/laravel/framework/pull/26261] to match the where method's signature. If you are overriding this method, you should update the method signature to match its parent:

/**
 * 指定したキー/値ペアの最初のアイテムを取得
 *
 * @param  string  $key
 * @param  mixed  $operator
 * @param  mixed  $value
 * @return mixed
 */
public function firstWhere($key, $operator = null, $value = null);

コンソールConsole

Kernel契約The Kernel Contract

影響の可能性: とても低いLikelihood Of Impact: Very Low

terminateメソッドがIlluminate\Contracts\Console\Kernel契約へ追加されました。このインターフェイスを実装している場合は、このメソッドを追加してください。The terminate method has been added to the Illuminate\Contracts\Console\Kernel contract[https://github.com/laravel/framework/pull/26393]. If you are implementing this interface, you should add this method to your implementation.

コンテナContainer

ジェネレータとタグ付けサービスGenerators & Tagged Services

影響の可能性: 中程度Likelihood Of Impact: Medium

コンテナのtaggedメソッドは、指定したタグのサービスに対し、PHPジェネレータの遅延インスタンス化を活用するようになりました。これにより、タグつけしたサービスを全部使用しない場合に、パフォーマンスの改善を達成しました。The container's tagged method now utilizes PHP generators to lazy-instantiate the services with a given tag. This provides a performance improvement if you are not utilizing every tagged service.

この変更により、taggedメソッドは配列(array)の代わりに、iterableを返すようになりました。このメソッドの返却値をタイプヒントしている場合は、iterableへ確実に変更してください。Because of this change, the tagged method now returns an iterable instead of an array. If you are type-hinting the return value of this method, you should ensure that your type-hint is changed to iterable.

付け加えると、$container->tagged('foo')[0]のように、配列のオフセット値により直接タグ付けサービスへアクセスすることは、もうできなくなりました。In addition, it is no longer possible to directly access a tagged service by its array offset value, such as $container->tagged('foo')[0].

resolveメソッドThe resolve Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

resolveメソッドは新しい論理値引数を受け取るようになりました。これはオブジェクトのインスタンス化の間に、(コールバックを解決する)イベントが発生させられるか/実行されるかを指示します。このメソッドをオーバーライドしている場合、親クラスのものと一致するようにメソッドの使用法を変更してください。The resolve method now accepts[https://github.com/laravel/framework/pull/27066] a new boolean parameter which indicates whether events (resolving callbacks) should be raised/executed during the instantiation of an object. If you are overriding this method, you should update the method signature to match its parent.

addContextualBindingメソッドThe addContextualBinding Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

addContextualBindingメソッドが、Illuminate\Contracts\Container\Container契約に追加されました。このインターフェイスを実装している場合は、このメソッドを追加してください。The addContextualBinding method was added to the Illuminate\Contracts\Container\Container contract[https://github.com/laravel/framework/pull/26551]. If you are implementing this interface, you should add this method to your implementation.

taggedメソッドThe tagged Method

影響の可能性: 低いLikelihood Of Impact: Low

taggedメソッドの使用法が変更されました。そして、配列の代わりにiterableを返すようになりました。皆さんコードの引数として、このメソッドの返却値を配列としてタイプヒントしている場合は、iterableへ変更してください。The tagged method signature has been changed[https://github.com/laravel/framework/pull/26953] and it now returns an iterable instead of an array. If you have type-hinted in your code some parameter which gets the return value of this method with array, you should modify the type-hint to iterable.

flushメソッドThe flush Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

flushメソッドがIlluminate\Contracts\Container\Container契約へ追加されました。このインターフェイスを実装している場合は、このメソッドを追加してください。The flush method was added to the Illuminate\Contracts\Container\Container contract[https://github.com/laravel/framework/pull/26477]. If you are implementing this interface, you should add this method to your implementation.

データベースDatabase

クオートしないMySQL JSON値Unquoted MySQL JSON Values

影響の可能性: 低いLikelihood Of Impact: Low

MySQLとMariaDBを使用している場合、クエリビルダはクオートしないJSON値を返すようになりました。この振る舞いは、サポートしている他のデータベースと一貫性を持たせるためです。The query builder will now return unquoted JSON values when using MySQL and MariaDB. This behavior is consistent with the other supported databases:

$value = DB::table('users')->value('options->language');

dump($value);

// Laravel5.7
'"en"'

// Laravel5.8
'en'

その結果として、->>操作子は必要なくなり、サポートされなくなりました。As a result, the ->> operator is no longer supported or necessary.

SQLiteSQLite

影響の可能性: 中程度Likelihood Of Impact: Medium

Laravel5.8がサポートする一番古いSQLiteバージョンはSQLite3.7.11です。より古いSQLiteバージョンを使用している場合は、アップデートしてください。SQLite3.8.8以上を推奨します。As of Laravel 5.8 the oldest supported SQLite version[https://github.com/laravel/framework/pull/25995] is SQLite 3.7.11. If you are using an older SQLite version, you should update it (SQLite 3.8.8 is recommended).

マイグレーションとbigIncrementsMigrations & bigIncrements

影響の可能性: なしLikelihood Of Impact: None

Laravel5.8では、マイグレーションスタブのデフォルトとして、IDカラムにbigIncrementsを使います。以前のバージョンでは、IDカラムはincrementsメソッドを使用し、生成されていました。As of Laravel 5.8[https://github.com/laravel/framework/pull/26472], migration stubs use the bigIncrements method on ID columns by default. Previously, ID columns were created using the increments method.

これは既存のプロジェクトのコードへ、影響を与えません。しかしながら、外部キーを同じタイプにするように気を付けてください。incrementsメソッドを使用して生成されたカラムは、bigIncrementsメソッドを使って生成したカラムを参照できないためです。This will not affect any existing code in your project; however, be aware that foreign key columns must be of the same type. Therefore, a column created using the increments method can not reference a column created using the bigIncrements method.

EloquentEloquent

不規則変化する複数形のモデル名Model Names Ending With Irregular Plurals

影響の可能性: 中程度Likelihood Of Impact: Medium

Laravel5.8では、複数後のモデル名で不規則変化する単語で終わる場合も、正しい複数形になるようになりました。As of Laravel 5.8, multi-word model names ending in a word with an irregular plural are now correctly pluralized[https://github.com/laravel/framework/pull/26421].

// Laravel5.7
App\Feedback.php -> feedback (正しい複数形)
App\UserFeedback.php -> user_feedbacks (間違った複数形)

// Laravel5.8
App\Feedback.php -> feedback (正しい複数形)
App\UserFeedback.php -> user_feedback (正しい複数形)

間違った複数形のモデルがある場合は、モデルの$tableプロパティを定義することにより、古いテーブル名を続けて使用できます。If you have a model that was incorrectly pluralized, you may continue using the old table name by defining a $table property on your model:

/**
 * モデルと関連するテーブル
 *
 * @var string
 */
protected $table = 'user_feedbacks';

IDが増加するカスタムピボットモデルCustom Pivot Models With Incrementing IDs

カスタムピボットモデルを使用する多対多リレーションを定義しており、そのピボットモデルが自動増分の主キーを持つ場合、カスタムピボットモデルクラスで確実にincrementingプロパティを定義し、trueをセットしてください。If you have defined a many-to-many relationship that uses a custom pivot model, and that pivot model has an auto-incrementing primary key, you should ensure your custom pivot model class defines an incrementing property that is set to true:

/**
 * IDが自動増分する
 *
 * @var bool
 */
public $incrementing = true;

loadCountメソッドThe loadCount Method

影響の可能性: 低いLikelihood Of Impact: Low

loadCountメソッドが、ベースのIlluminate\Database\Eloquent\Modelクラスへ追加されました。皆さんのアプリケーションでもloadCountメソッドを定義している場合、Eloquentの定義と名前が衝突してしまいます。A loadCount method has been added to the base Illuminate\Database\Eloquent\Model class. If your application also defines a loadCount method, it may conflict with Eloquent's definition.

originalIsEquivalentメソッドThe originalIsEquivalent Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Database\Eloquent\Concerns\HasAttributesトレイトのoriginalIsEquivalentメソッドが、protectedからpublic変更されましたThe originalIsEquivalent method of the Illuminate\Database\Eloquent\Concerns\HasAttributes trait has been changed[https://github.com/laravel/framework/pull/26391] from protected to public.

ソフト削除のdeleted_atプロパティの自動キャストAutomatic Soft-Deleted Casting Of deleted_at Property

影響の可能性: 低いLikelihood Of Impact: Low

Illuminate\Database\Eloquent\SoftDeletesトレイトを使用しているEloquentモデルを使用している場合、deleted_atプロパティはCarbonインスタンスへ、自動的にキャストされるようになりました。この振る舞いはプロパティのカスタムアクセサを書くか、casts属性へ追加することによりオーバーライドできます。The deleted_at property will now be automatically casted[https://github.com/laravel/framework/pull/26985] to a Carbon instance when your Eloquent model uses the Illuminate\Database\Eloquent\SoftDeletes trait. You can override this behavior by writing your custom accessor for that property or by manually adding it to the casts attribute:

protected $casts = ['deleted_at' => 'string'];

BelongsToのgetForeignKeygetOwnerKeyメソッドBelongsTo getForeignKey & getOwnerKey Methods

影響の可能性: 低いLikelihood Of Impact: Low

Laravelにより提供されている他のリレーションのメソッド名と統一するために、BelongsTogetForeignKeygetQualifiedForeignKeygetOwnerKeyメソッドは、getForeignKeyNamegetQualifiedForeignKeyNamegetOwnerKeyNameへ名前が変わりました。The getForeignKey, getQualifiedForeignKey, and getOwnerKey methods of the BelongsTo relationship have been renamed to getForeignKeyName, getQualifiedForeignKeyName, and getOwnerKeyName respectively, making the method names consistent with the other relationships offered by Laravel.

環境変数のパースEnvironment Variable Parsing

影響の可能性: 高いLikelihood Of Impact: High

.envファイルのパースに利用している、phpdotenvパッケージが新しいメジャーバージョンをリリースしました。そのため、envヘルパ画の戻り値に影響が起きます。クオートされていない#文字は、値の一部ではなくコメントとして扱われるようになりました。The phpdotenv[https://github.com/vlucas/phpdotenv] package that is used to parse .env files has released a new major version, which may impact the results returned from the env helper. Specifically, the # character in an unquoted value will now be considered a comment instead of part of the value:

以前の振る舞い:Previous behavior:

ENV_VALUE=foo#bar

env('ENV_VALUE'); // foo#bar

新しい振る舞い:New behavior:

ENV_VALUE=foo#bar
env('ENV_VALUE'); // foo

もとの振る舞いにするには、環境変数をクオートしてください。To preserve the previous behavior, you may wrap the environment values in quotes:

ENV_VALUE="foo#bar"

env('ENV_VALUE'); // foo#bar

より詳細な情報は、phpdotenvアップグレードガイドを参照してください。For more information, please refer to the phpdotenv upgrade guide[https://github.com/vlucas/phpdotenv/blob/master/UPGRADING.md].

イベントEvents

fireメソッドThe fire Method

影響の可能性: 低いLikelihood Of Impact: Low

Laravel5.4で非推奨になっていた、Illuminate\Events\Dispatcherクラスのfireメソッドが、削除されました。 代わりに、dispatchメソッドを使用してください。

例外処理Exception Handling

ExceptionHandler契約The ExceptionHandler Contract

影響の可能性: 低いLikelihood Of Impact: Low

shouldReportメソッドがIlluminate\Contracts\Debug\ExceptionHandler契約へ追加されました。このインターフェイスを実装している場合は、メソッドを追加してください。The shouldReport method has been added to the Illuminate\Contracts\Debug\ExceptionHandler contract[https://github.com/laravel/framework/pull/26193]. If you are implementing this interface, you should add this method to your implementation.

renderHttpExceptionメソッドThe renderHttpException Method

影響の可能性: 低いLikelihood Of Impact: Low

Illuminate\Foundation\Exceptions\HandlerクラスのrenderHttpExceptionメソッドの使用法が変更されました。例外ハンドラのこのメソッドをオーバーライドしている場合は、親クラスとメソッドの使い方を合わせるように変更してください。The renderHttpException method signature of the Illuminate\Foundation\Exceptions\Handler class has changed[https://github.com/laravel/framework/pull/25975]. If you are overriding this method in your exception handler, you should update the method signature to match its parent:

/**
 * 渡されたHttpExceptionをレンダーする
 *
 * @param  \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface  $e
 * @return \Symfony\Component\HttpFoundation\Response
 */
protected function renderHttpException(HttpExceptionInterface $e);

メールMail

Markdownファイルのディレクトリ変更Markdown File Directory Change

影響の可能性: 高いLikelihood Of Impact: High

LaravelのMarkdownメールコンポーネントをvendor:publishコマンドでリソース公開している場合は、/resources/views/vendor/mail/markdownディレクトリを/resources/views/vendor/mail/textへリネームしてくださいIf you have published Laravel's Markdown mail components using the vendor:publish command, you should rename the /resources/views/vendor/mail/markdown directory to /resources/views/vendor/mail/text.

さらに、markdownComponentPathsメソッドはtextComponentPathsリネームされました。このメソッドをオーバーライドしている場合は、親のクラスへ合わせるようにメソッド名を変更してください。In addition, the markdownComponentPaths method has been renamed[https://github.com/laravel/framework/pull/26938] to textComponentPaths. If you are overriding this method, you should update the method name to match its parent.

PendingMailクラスのメソッド使用法変更Method Signature Changes In The PendingMail Class

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Mail\Mailableの代わりにIlluminate\Contracts\Mail\Mailableを受け付けるため、Illuminate\Mail\PendingMailクラスのsendsendNowqueuelaterfillメソッドは変更されました。これらのメソッドをオーバーライドしている場合は、親クラスと使用法を合わせるように更新してください。The send, sendNow, queue, later and fill methods of the Illuminate\Mail\PendingMail class have been changed[https://github.com/laravel/framework/pull/26790] to accept an Illuminate\Contracts\Mail\Mailable instance instead of Illuminate\Mail\Mailable. If you are overriding some of these methods, you should update their signature to match its parent.

キューQueue

Pheanstalk4.0Pheanstalk 4.0

影響の可能性: 中程度Likelihood Of Impact: Medium

Laravel5.8は、Pheanstalkキューライブラリの~4.0をサポートしました。皆さんのアプリケーションでPheanstalkライブラリを使用している場合は、Composerを使用し~4.0リリースへライブラリをアップグレードしてください。Laravel 5.8 provides support for the ~4.0 release of the Pheanstalk queue library. If you are using Pheanstalk library in your application, please upgrade your library to the ~4.0 release via Composer.

Job契約The Job Contract

影響の可能性: とても低いLikelihood Of Impact: Very Low

isReleasedhasFailedmarkAsFailedメソッドが、Illuminate\Contracts\Queue\Job契約へ追加されました。このインターフェイスを実装してる場合は、これらのメソッドを追加してください。The isReleased, hasFailed and markAsFailed methods have been added to the Illuminate\Contracts\Queue\Job contract[https://github.com/laravel/framework/pull/26908]. If you are implementing this interface, you should add these methods to your implementation.

Job::failedFailingJobクラスThe Job::failed & FailingJob Class

影響の可能性: とても低いLikelihood Of Impact: Very Low

Laravel5.7ではキューされたジョブが失敗したときに、キューワーカはFailingJob::handleメソッドを実行していました。Laravel5.8では、FailingJobクラスに含まれていたロジックは、ジョブクラス自身のfailメソッドへそのまま移動されました。このため、Illuminate\Contracts\Queue\Job契約へfailメソッドが追加されました。When a queued job failed in Laravel 5.7, the queue worker executed the FailingJob::handle method. In Laravel 5.8, the logic contained in the FailingJob class has been moved to a fail method directly on the job class itself. Because of this, a fail method has been added to the Illuminate\Contracts\Queue\Job contract.

ベースのIlluminate\Queue\Jobs\Jobクラスがfailの実装を含んでも、通常のアプリケーションコードではコードの変更は必要ありません。しかし、Laravelにより提供されているベースのジョブクラスを拡張しないで、ジョブクラスを活用するカスタムキュードライバを構築している場合は、カスタムジョブクラスへfailメソッドを自分で実装する必要があります。実装の例として、Laravelのベースジョブクラスを参照してください。The base Illuminate\Queue\Jobs\Job class contains the implementation of fail and no code changes should be required by typical application code. However, if you are building custom queue driver which utilizes a job class that does not extend the base job class offered by Laravel, you should implement the fail method manually in your custom job class. You may refer to Laravel's base job class as a reference implementation.

この変更により、ジョブの削除過程をカスタムキュードライバがよりコントロールできるようになりました。This change allows custom queue drivers to have more control over the job deletion process.

Redis Blocking PopRedis Blocking Pop

影響の可能性: とても低いLikelihood Of Impact: Very Low

Redisキュードライバの"blocking pop"機能の使用が安全になりました。以前は、ジョブ再取得と同時にRedisサーバかワーカがクラッシュすると、キューされたジョブを失う機会が多少ありました。Blocking popが安全になったため、各Laravelキューに対し新しいRedisは、:notifyサフィックス付けてリストします。Using the "blocking pop" feature of the Redis queue driver is now safe. Previously, there was a small chance that a queued job could be lost if the Redis server or worker crashed at the same time the job was retrieved. In order to make blocking pops safe, a new Redis list with suffix :notify is created for each Laravel queue.

リクエストRequests

TransformsRequestミドルウェアThe TransformsRequest Middleware

影響の可能性: 低いLikelihood Of Impact: Low

Illuminate\Foundation\Http\Middleware\TransformsRequestミドルウェアのtransformメソッドは、入力が配列のときに「完全な」リクエスト入力キーを受け入れるようになりました。The transform method of the Illuminate\Foundation\Http\Middleware\TransformsRequest middleware now receives the "fully-qualified" request input key when the input is an array:

'employee' => [
    'name' => 'Taylor Otwell',
],

/**
 * 渡された値を変形する
 *
 * @param  string  $key
 * @param  mixed  $value
 * @return mixed
 */
protected function transform($key, $value)
{
    dump($key); // 'employee.name' (Laravel5.8)
    dump($key); // 'name' (Laravel5.7)
}

ルートRouting

UrlGenerator契約The UrlGenerator Contract

影響の可能性: とても低いLikelihood Of Impact: Very Low

previousメソッドが、Illuminate\Contracts\Routing\UrlGenerator契約へ追加されました。このインターフェイスを実装している場合は、メソッドを追加してください。The previous method has been added to the Illuminate\Contracts\Routing\UrlGenerator contract[https://github.com/laravel/framework/pull/25616]. If you are implementing this interface, you should add this method to your implementation.

Illuminate\Routing\UrlGeneratorcachedSchemaプロパティThe cachedSchema Property Of Illuminate\Routing\UrlGenerator

影響の可能性: とても低いLikelihood Of Impact: Very Low

Laravel5.7で非推奨になっていた、Illuminate\Routing\UrlGenerator$cachedSchemaプロパティ名が、$cachedScheme変更されましたThe $cachedSchema property name (which has been deprecated in Laravel 5.7) of Illuminate\Routing\UrlGenerator has been changed to[https://github.com/laravel/framework/pull/26728] $cachedScheme.

セッションSessions

StartSessionミドルウェアThe StartSession Middleware

影響の可能性: とても低いLikelihood Of Impact: Very Low

セッションの維持ロジックをterminate()メソッドからhandle()メソッドへ移動しました。これらのメソッドをオーバーライドしている場合は、この変更を反映するように更新してください。The session persistence logic has been moved from the terminate() method to the handle() method[https://github.com/laravel/framework/pull/26410]. If you are overriding one or both of these methods, you should update them to reflect these changes.

サポートSupport

ヘルパから文字列と配列クラスへPrefer String And Array Classes Over Helpers

影響の可能性: 中程度Likelihood Of Impact: Medium

すべてのarray_*str_*グローバルヘルパが、非推奨となりましたIlluminate\Support\ArrIlluminate\Support\Strのメソッドを直接使用してください。All array_* and str_* global helpers have been deprecated[https://github.com/laravel/framework/pull/26898]. You should use the Illuminate\Support\Arr and Illuminate\Support\Str methods directly.

全ての配列と文字列のグローバル関数の後方互換性層を提供する、新しいlaravel/helpersパッケージへヘルパは移動されたため、この変更はmediumと記載しました。The impact of this change has been marked as medium since the helpers have been moved to the new laravel/helpers[https://github.com/laravel/helpers] package which offers a backwards compatibility layer for all of the global array and string functions.

遅延サービスプロバイダDeferred Service Providers

影響の可能性: 中程度Likelihood Of Impact: Medium

プロバイダを遅延させるかどうかを示すための、サービスプロバイダのdefer論理プロパティは、非推奨となりました。そのサービスプロバイダを遅延させるように指示するには、Illuminate\Contracts\Support\DeferrableProvider契約を実装してください。The defer boolean property on the service provider which is/was used to indicate if a provider is deferred has been deprecated[https://github.com/laravel/framework/pull/27067]. In order to mark the service provider as deferred it should implement the Illuminate\Contracts\Support\DeferrableProvider contract.

リードオンリーenvヘルパRead-Only env Helper

影響の可能性: 低いLikelihood Of Impact: Low

以前のenvヘルパは、実行時に変更された環境変数から値を取得していました。Laravel5.8から、環境変数値が変わらないように取り扱います。実行時に環境変数を変更したい場合は、configヘルパを使い取得できる設定値の使用を考慮してください。Previously, the env helper could retrieve values from environment variables which were changed at runtime. In Laravel 5.8, the env helper treats environment variables as immutable. If you would like to change an environment variable at runtime, consider using a configuration value that can be retrieved using the config helper:

以前の振る舞い:Previous behavior:

dump(env('APP_ENV')); // local

putenv('APP_ENV=staging');

dump(env('APP_ENV')); // staging

新しい振る舞い:New behavior:

dump(env('APP_ENV')); // local

putenv('APP_ENV=staging');

dump(env('APP_ENV')); // local

テストTesting

setUptearDownメソッドThe setUp & tearDown Methods

setUptearDownメソッドは、voidを返却タイプとして要求するようになりました。The setUp and tearDown methods now require a void return type:

protected function setUp(): void
protected function tearDown(): void

PHPUnit 8PHPUnit 8

影響の可能性: 状況によるLikelihood Of Impact: Optional

Laravel5.8ではPHPUnit7をデフォルトで使用します。しかしながら、PHP7.2以上が必要なPHPUnit8へアップグレードする選択肢もあります。詳細は、PHPUnit8のリリースアナウンスメントの変更一覧へ一通り目を通してください。By default, Laravel 5.8 uses PHPUnit 7. However, you may optionally upgrade to PHPUnit 8, which requires PHP >= 7.2. In addition, please read through the entire list of changes in the PHPUnit 8 release announcement[https://phpunit.de/announcements/phpunit-8.html].

バリデーションValidation

Validator契約The Validator Contract

影響の可能性: とても低いLikelihood Of Impact: Very Low

validatedメソッドが、Illuminate\Contracts\Validation\Validator契約へ追加されましたThe validated method was added to the Illuminate\Contracts\Validation\Validator contract[https://github.com/laravel/framework/pull/26419]:

/**
 * バリデートされた属性と値の取得
 *
 * @return array
 */
public function validated();

このインターフェイスを実装してる場合は、メソッドを追加してください。If you are implementing this interface, you should add this method to your implementation.

ValidatesAttributesトレイトThe ValidatesAttributes Trait

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Validation\Concerns\ValidatesAttributesトレイトのparseTablegetQueryColumnrequireParameterCountメソッドをprotectedからpublicに変更しました。The parseTable, getQueryColumn and requireParameterCount methods of the Illuminate\Validation\Concerns\ValidatesAttributes trait have been changed from protected to public.

DatabasePresenceVerifierクラスThe DatabasePresenceVerifier Class

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Validation\DatabasePresenceVerifierクラスのtableメソッドをprotectedからpublicに変更しました。The table method of the Illuminate\Validation\DatabasePresenceVerifier class has been changed from protected to public.

ValidatorクラスThe Validator Class

影響の可能性: とても低いLikelihood Of Impact: Very Low

Illuminate\Validation\ValidatorクラスのgetPresenceVerifierForメソッドをprotectedからpublic変更しましたThe getPresenceVerifierFor method of the Illuminate\Validation\Validator class has been changed[https://github.com/laravel/framework/pull/26717] from protected to public.

メールバリデーションEmail Validation

影響の可能性: とても低いLikelihood Of Impact: Very Low

メールのバリデーションルールをメールがRFC6530準拠するかをチェックするようになりました。SwiftMailerが使用しているバリデーションロジックと統一しました。Laravel5.7では、emailルールはメールがRFC822を準拠しているかのみを検証していました。The email validation rule now checks if the email is RFC6530[https://tools.ietf.org/html/rfc6530] compliant, making the validation logic consistent with the logic used by SwiftMailer. In Laravel 5.7, the email rule only verified that the email was RFC822[https://tools.ietf.org/html/rfc822] compliant.

これにより、Laravel5.8を使用すると以前は誤って有効でないと判断したメールを有効と判断するようになりました。(例:hej@bär.se)一般的にはバグフィックスとして考えるべきでしょう。しかしながら、これは注意の必要な互換性のない変更としてリストされています。この変更により、問題が起きたらお知らせくださいTherefore, when using Laravel 5.8, emails that were previously incorrectly considered invalid will now be considered valid (e.g hej@bär.se). Generally, this should be considered a bug fix; however, it is listed as a breaking change out of caution. Please let us know if you encounter any issues surrounding this change[https://github.com/laravel/framework/pull/26503].

ビューView

getDataメソッドThe getData Method

影響の可能性: とても低いLikelihood Of Impact: Very Low

getDataメソッドが、Illuminate\Contracts\View\View契約へ追加されました。このインターフェイスを実装している場合は、メソッドを追加してください。The getData method was added to the Illuminate\Contracts\View\View contract[https://github.com/laravel/framework/pull/26754]. If you are implementing this interface, you should add this method to your implementation.

通知Notifications

Nexmo/Slack通知チャンネルNexmo / Slack Notification Channels

影響の可能性: 高いLikelihood Of Impact: High

NexmoとSlackの通知チャンネルをファーストパーティパッケージとして独立させました。これらのチャンネルをアプリケーションで使用する場合は、以下のパッケージをインストールしてください。The Nexmo and Slack Notification channels have been extracted into first-party packages. To use these channels in your application, require the following packages:

composer require laravel/nexmo-notification-channel
composer require laravel/slack-notification-channel

その他Miscellaneous

laravel/laravelGitHubリポジトリで、変更を確認することをおすすめします。これらの変更は必須ではありませんが、皆さんのアプリケーションではファイルの同期を保つほうが良いでしょう。変更のいくつかは、このアップグレードガイドで取り扱っていますが、設定ファイルやコメントなどの変更は取り扱っていません。変更は簡単にGitHubの比較ツールで閲覧でき、みなさんにとって重要な変更を選択できます。We also encourage you to view the changes in the laravel/laravel GitHub repository[https://github.com/laravel/laravel]. While many of these changes are not required, you may wish to keep these files in sync with your application. Some of these changes will be covered in this upgrade guide, but others, such as changes to configuration files or comments, will not be. You can easily view the changes with the GitHub comparison tool[https://github.com/laravel/laravel/compare/5.7...master] and choose which updates are important to you.

章選択

設定

明暗テーマ
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!…]形式の挿入削除行の表示形式です。

Pagination和文
ペジネーション
ペギネーション
ページネーション
ページ付け
Scaffold和文
スカフォールド
スキャフォールド
型枠生成
本文フォント

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

コードフォント

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

保存内容リセット

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

ヘッダー項目移動

キーボード操作