影響度の高い変更High Impact Changes
- 依存パッケージの更新Updating Dependencies[#updating-dependencies]
- 最低安定度の更新Updating Minimum Stability[#updating-minimum-stability]
影響度が中程度の変更Medium Impact Changes
- データベース構文Database Expressions[#database-expressions]
- モデルの"Dates"プロパティModel "Dates" Property[#model-dates-property]
- Monolog3Monolog 3[#monolog-3]
- RedisキャッシュタグRedis Cache Tags[#redis-cache-tags]
- サービスのモックService Mocking[#service-mocking]
- 言語ディレクトリThe Language Directory[#language-directory]
影響度の低い変更Low Impact Changes
- クロージャバリデーションルールメッセージClosure Validation Rule Messages[#closure-validation-rule-messages]
- フォームリクエストの
after
メソッドForm Requestafter
Method[#form-request-after-method] - Publicパスの結合Public Path Binding[#public-path-binding]
- クエリ例外のコンストラクタQuery Exception Constructor[#query-exception-constructor]
- レート制限の戻り値Rate Limiter Return Values[#rate-limiter-return-values]
Redirect::home
メソッドTheRedirect::home
Method[#redirect-home]Bus::dispatchNow
メソッドTheBus::dispatchNow
Method[#dispatch-now]registerPolicies
メソッドTheregisterPolicies
Method[#register-policies]- ULIDカラムULID Columns[#ulid-columns]
9.xから10.0へのアップグレードUpgrading to 10.0 from 9.x
アップデート見積もり時間:10分Estimated Upgrade Time: 10 Minutes
Laravel Shift を使用すると、アプリケーションのアップグレードを自動化できます。[!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. Want to save time? You can use Laravel Shift[https://laravelshift.com/] to help automate your application upgrades.
依存パッケージのアップデートUpdating Dependencies
影響の可能性: 高いLikelihood Of Impact: High
PHP8.1.0必須PHP 8.1.0 Required
現バージョンのLaravelは、PHP8.1.0以上が必要です。Laravel now requires PHP 8.1.0 or greater.
Composer2.2.0必須Composer 2.2.0 Required
現バージョンのLaravelは、Composer2.2.0以上が必要です。Laravel now requires Composer[https://getcomposer.org] 2.2.0 or greater.
Composerの依存パッケージComposer Dependencies
アプリケーションのcomposer.json
ファイルにある、以下の依存パッケージを更新してください。You
should
update
the
following
dependencies
in
your
application's
composer.json
file:
laravel/framework
を^10.0
laravel/framework
to^10.0
laravel/sanctum
を^3.2
laravel/sanctum
to^3.2
doctrine/dbal
を^3.0
doctrine/dbal
to^3.0
spatie/laravel-ignition
を^2.0
spatie/laravel-ignition
to^2.0
laravel/passport
を^11.0
(アップグレードガイド)laravel/passport
to^11.0
(Upgrade Guide[https://github.com/laravel/passport/blob/11.x/UPGRADE.md])laravel/ui
を^4.0
laravel/ui
to^4.0
Sanctum2.xリリースシリーズから3.xへアップグレードする場合は、Sanctumアップグレードガイドを参照してください。If you are upgrading to Sanctum 3.x from the 2.x release series, please consult the Sanctum upgrade guide[https://github.com/laravel/sanctum/blob/3.x/UPGRADE.md].
さらに、PHPUnit10を使用したい場合は、アプリケーションのphpunit.xml
設定ファイルの<coverage>
セクションから、processUncoveredFiles
属性を削除する必要があります。次に、アプリケーションのcomposer.json
ファイルで、以下の依存関係を更新します。Furthermore,
if
you
wish
to
use
PHPUnit
10[https://phpunit.de/announcements/phpunit-10.html],
you
should
delete
the
processUncoveredFiles
attribute
from
the
<coverage>
section
of
your
application's
phpunit.xml
configuration
file.
Then,
update
the
following
dependencies
in
your
application's
composer.json
file:
nunomaduro/collision
を^7.0
nunomaduro/collision
to^7.0
phpunit/phpunit
を^10.0
phpunit/phpunit
to^10.0
最後に、アプリケーションで使用しているその他のサードパーティパッケージを調べ、Laravel10のサポートに適したバージョンを確実に使用してください。Finally, examine any other third-party packages consumed by your application and verify you are using the proper version for Laravel 10 support.
最低安定度Minimum Stability
アプリケーションのcomposer.json
ファイルのminimum-stability
設定をstable
へ更新する必要があります。もしくは、minimum-stability
のデフォルト値はstable
なので、アプリケーションの
composer.json
ファイルからこの設定を削除してください。You
should
update
the
minimum-stability
setting
in
your
application's
composer.json
file
to
stable
.
Or,
since
the
default
value
of
minimum-stability
is
stable
,
you
may
delete
this
setting
from
your
application's
composer.json
file:
"minimum-stability": "stable",
アプリケーションApplication
Publicパスの結合Public Path Binding
影響の可能性: 低いLikelihood Of Impact: Low
アプリケーションでコンテナへpath.public
を結合し、「公開パス」をカスタマイズしている場合は、代わりに
Illuminate\Foundation\Application
オブジェクトが提供するusePublicPath
メソッドを呼び出すようにコードを更新する必要があります。If
your
application
is
customizing
its
"public
path"
by
binding
path.public
into
the
container,
you
should
instead
update
your
code
to
invoke
the
usePublicPath
method
offered
by
the
Illuminate\Foundation\Application
object:
app()->usePublicPath(__DIR__.'/public');
許可Authorization
registerPolicies
メソッドThe
registerPolicies
Method
影響の可能性: 低いLikelihood Of Impact: Low
AuthServiceProvider
のregisterPolicies
メソッドをフレームワークが自動的に呼び出すようになりました。したがって、アプリケーションのAuthServiceProvider
のboot
メソッドから、このメソッドの呼び出しを削除できます。The
registerPolicies
method
of
the
AuthServiceProvider
is
now
invoked
automatically
by
the
framework.
Therefore,
you
may
remove
the
call
to
this
method
from
the
boot
method
of
your
application's
AuthServiceProvider
.
キャッシュCache
RedisキャッシュタグRedis Cache Tags
影響の可能性: 中程度Likelihood Of Impact: Medium
Cache::tags()
は、Memcachedを使用しているアプリケーションにのみに推奨します。アプリケーションのキャッシュドライバとしてRedisを使用している場合は、Memcachedへ移行するか、別のソリューションの使用を検討すべきです。Usage
of
Cache::tags()
is
only
recommended
for
applications
using
Memcached.
If
you
are
using
Redis
as
your
application's
cache
driver,
you
should
consider
moving
to
Memcached
or
using
an
alternative
solution.
データベースDatabase
データベース構文Database Expressions
影響の可能性: 中程度Likelihood Of Impact: Medium
データベースの「構文」(通常は
DB::raw
により生成)は、将来的に追加機能を提供するため、Laravel10.xで書き直しました。特に、構文の素の文字列の値は、構文のgetValue(Grammar
$grammar)
メソッドで取得する必要があります。(string)
を使う構文から文字列へのキャストは、既にサポートしていません。Database
"expressions"
(typically
generated
via
DB::raw
)
have
been
rewritten
in
Laravel
10.x
to
offer
additional
functionality
in
the
future.
Notably,
the
grammar's
raw
string
value
must
now
be
retrieved
via
the
expression's
getValue(Grammar
$grammar)
method.
Casting
an
expression
to
a
string
using
(string)
is
no
longer
supported.
**通常、これはエンドユーザーのアプリケーションには無影響です。**しかし、もしアプリケーションで(string)
を使用してデータベース式を文字列へ手作業でキャストしたり、構文に対して__toString
メソッドを直接呼び出している場合は、代わりにgetValue
メソッドを呼び出すようにコードを更新する必要があります。Typically,
this
does
not
affect
end-user
applications;
however,
if
your
application
is
manually
casting
database
expressions
to
strings
using
(string)
or
invoking
the
__toString
method
on
the
expression
directly,
you
should
update
your
code
to
invoke
the
getValue
method
instead:
use Illuminate\Support\Facades\DB;
$expression = DB::raw('select 1');
$string = $expression->getValue(DB::connection()->getQueryGrammar());
クエリ例外コンストラクタQuery Exception Constructor
影響の可能性: かなり低いLikelihood Of Impact: Very Low
Illuminate\Database\QueryException
のコンストラクターで、文字列の接続名を最初の引数に取るようにしました。アプリケーションがこの例外を手作業で投げている場合は、それに応じてコードを調整する必要があります。The
Illuminate\Database\QueryException
constructor
now
accepts
a
string
connection
name
as
its
first
argument.
If
your
application
is
manually
throwing
this
exception,
you
should
adjust
your
code
accordingly.
ULIDカラムULID Columns
影響の可能性: 低いLikelihood Of Impact: Low
マイグレーションで、ulid
メソッドを引数なしで呼び出すと、カラムはulid
という名前になります。Laravelの以前のリリースでは、引数なしでこのメソッドを呼び出すと、誤ってuuid
という名前のカラムが作成されていました。When
migrations
invoke
the
ulid
method
without
any
arguments,
the
column
will
now
be
named
ulid
.
In
previous
releases
of
Laravel,
invoking
this
method
without
any
arguments
created
a
column
erroneously
named
uuid
:
$table->ulid();
ulid
メソッドを呼び出すとき、明示的にカラム名を指定するには、そのカラム名をメソッドへ渡してください。To
explicitly
specify
a
column
name
when
invoking
the
ulid
method,
you
may
pass
the
column
name
to
the
method:
$table->ulid('ulid');
EloquentEloquent
モデルの"Dates"プロパティModel "Dates" Property
影響の可能性: 中程度Likelihood Of Impact: Medium
Eloquentモデルで非推奨になっていた$dates
プロパティを削除しました。アプリケーションでは、$casts
プロパティを使用する必要があります。The
Eloquent
model's
deprecated
$dates
property
has
been
removed.
Your
application
should
now
use
the
$casts
property:
protected $casts = [
'deployed_at' => 'datetime',
];
多言語化Localization
LanguageディレクトリThe Language Directory
影響の可能性: なしLikelihood Of Impact: None
既存のアプリケーションには関係ありませんが、Laravelアプリケーションのスケルトンは、lang
ディレクトリをデフォルトで用意しなくなりました。代わりに、新しいLaravelアプリケーションを書く際には、lang:publish
Artisanコマンドを使用してリソース公開してください。Though
not
relevant
to
existing
applications,
the
Laravel
application
skeleton
no
longer
contains
the
lang
directory
by
default.
Instead,
when
writing
new
Laravel
applications,
it
may
be
published
using
the
lang:publish
Artisan
command:
php artisan lang:publish
ログLogging
Monolog3Monolog 3
影響の可能性: 中程度Likelihood Of Impact: Medium
LaravelのMonolog依存バージョンをMonolog3.xへ更新しました。アプリケーション内でMonologと直接やりとりする場合は、Monologのアップグレードガイドを確認する必要があります。Laravel's Monolog dependency has been updated to Monolog 3.x. If you are directly interacting with Monolog within your application, you should review Monolog's upgrade guide[https://github.com/Seldaek/monolog/blob/main/UPGRADE.md].
BugSnagやRollbarなどのサードパーティのログサービスを使用している場合、それらのサードパーティのパッケージをMonolog3.xとLaravel10.xをサポートするバージョンへアップグレードする必要がある場合があります。If you are using third-party logging services such as BugSnag or Rollbar, you may need to upgrade those third-party packages to a version that supports Monolog 3.x and Laravel 10.x.
キューQueues
The
Bus::dispatchNow
MethodThe
Bus::dispatchNow
Method
影響の可能性: 低いLikelihood Of Impact: Low
非推奨にしていたBus::dispatchNow
とdispatch_now
メソッドを削除しました。代わりに、アプリケーションでは、それぞれBus::dispatchSync
かdispatch_sync
メソッドを使用する必要があります。The
deprecated
Bus::dispatchNow
and
dispatch_now
methods
have
been
removed.
Instead,
your
application
should
use
the
Bus::dispatchSync
and
dispatch_sync
methods,
respectively.
dispatch()
ヘルパの戻り値The
dispatch()
Helper
Return
Value
影響の可能性: 低いLikelihood Of Impact: Low
Illuminate\Contracts\Queue
を実装していないクラスで、dispatch
を起動すると、以前はそのクラスのhandle
メソッドの結果を返していました。しかし、これは
Illuminate\Foundation\Bus\PendingBatch
インスタンスを返すようになりました。以前の動作を再現するには、dispatch_sync()
を使ってください。Invoking
dispatch
with
a
class
that
does
not
implement
Illuminate\Contracts\Queue
would
previously
return
the
result
of
the
class's
handle
method.
However,
this
will
now
return
an
Illuminate\Foundation\Bus\PendingBatch
instance.
You
may
use
dispatch_sync()
to
replicate
the
previous
behavior.
ルートRouting
ミドルウェアエイリアスMiddleware Aliases
影響の可能性: 条件によるLikelihood Of Impact: Optional
新しいLaravelアプリケーションでは、App\Http\Kernel
クラスの$routeMiddleware
プロパティは、その目的をよりよく表すために$middlewareAliases
へ名前を変更しました。既存のアプリケーションでこのプロパティの名前を変更することは歓迎しますが、必須ではありません。In
new
Laravel
applications,
the
$routeMiddleware
property
of
the
App\Http\Kernel
class
has
been
renamed
to
$middlewareAliases
to
better
reflect
its
purpose.
You
are
welcome
to
rename
this
property
in
your
existing
applications;
however,
it
is
not
required.
レート制限の戻り値Rate Limiter Return Values
影響の可能性: 低いLikelihood Of Impact: Low
RateLimiter::attempt
メソッドを呼び出すと、指定したクロージャが返す値をメソッドからも返すようにしました。何も返さないかnull
を返すと、attempt
メソッドはtrue
を返します。When
invoking
the
RateLimiter::attempt
method,
the
value
returned
by
the
provided
closure
will
now
be
returned
by
the
method.
If
nothing
or
null
is
returned,
the
attempt
method
will
return
true
:
$value = RateLimiter::attempt('key', 10, fn () => ['example'], 1);
$value; // ['example']
Redirect::home
メソッドThe
Redirect::home
Method
影響の可能性: かなり低いLikelihood Of Impact: Very Low
非推奨だったRedirect::home
メソッドを削除しました。代わりに、アプリケーションでは明示的に名付けたルートへリダイレクトする必要があります。The
deprecated
Redirect::home
method
has
been
removed.
Instead,
your
application
should
redirect
to
an
explicitly
named
route:
return Redirect::route('home');
テストTesting
サービスのモックService Mocking
影響の可能性: 中程度Likelihood Of Impact: Medium
非推奨だったMocksApplicationServices
トレイトをフレームワークから削除しました。このトレイトはexpectsEvents
、expectsJobs
、expectsNotifications
といったテストメソッドを提供していました。The
deprecated
MocksApplicationServices
trait
has
been
removed
from
the
framework.
This
trait
provided
testing
methods
such
as
expectsEvents
,
expectsJobs
,
and
expectsNotifications
.
もしあなたのアプリケーションでこれらのメソッドを使用するなら、それぞれEvent::fake
、Bus::fake
、Notification::fake
へ移行することをお勧めします。フェイクを使ったモックについては、フェイクしようとしているコンポーネントの対応するドキュメントで詳しく説明されています。If
your
application
uses
these
methods,
we
recommend
you
transition
to
Event::fake
,
Bus::fake
,
and
Notification::fake
,
respectively.
You
can
learn
more
about
mocking
via
fakes
in
the
corresponding
documentation
for
the
component
you
are
attempting
to
fake.
バリデーションValidation
クロージャバリデーションルールメッセージClosure Validation Rule Messages
影響の可能性: かなり低いLikelihood Of Impact: Very Low
クロージャベースのカスタムバリデーションルールを書くとき、$fail
コールバックを複数回呼び出すと、前のメッセージを上書きする代わりに、メッセージを配列へ追加するようになりました。通常、これはアプリケーションに影響を与えることはありません。When
writing
closure
based
custom
validation
rules,
invoking
the
$fail
callback
more
than
once
will
now
append
the
messages
to
an
array
instead
of
overwriting
the
previous
message.
Typically,
this
will
not
affect
your
application.
加えて、$fail
コールバックはオブジェクトを返すようになりました。これまでバリデーションクロージャの戻り値の型をタイプヒントしていた場合は、タイプヒントを更新する必要があります。In
addition,
the
$fail
callback
now
returns
an
object.
If
you
were
previously
type-hinting
the
return
type
of
your
validation
closure,
this
may
require
you
to
update
your
type-hint:
public function rules()
{
'name' => [
function ($attribute, $value, $fail) {
$fail('validation.translation.key')->translate();
},
],
}
バリデーションメッセージとクロージャルールValidation Messages and Closure Rules
影響の可能性: かなり低いLikelihood Of Impact: Very Low
以前は、クロージャベースのバリデーションルールへ注入する、$fail
コールバックに配列を指定し、個別のキーへ失敗メッセージを割り当て可能でした。しかし、現行では、第1引数にキー、第2引数に失敗メッセージを指定する必要があります。Previously,
you
could
assign
a
failure
message
to
a
different
key
by
providing
an
array
to
the
$fail
callback
injected
into
Closure
based
validation
rules.
However,
you
should
now
provide
the
key
as
the
first
argument
and
the
failure
message
as
the
second
argument:
Validator::make([
'foo' => 'string',
'bar' => [function ($attribute, $value, $fail) {
$fail('foo', 'Something went wrong!');
}],
]);
フォームリクエストのafterメソッドForm Request After Method
影響の可能性: かなり低いLikelihood Of Impact: Very Low
フォームリクエスト内でafter
メソッドは、Laravelの予約語にしました。フォームリクエストでafter
メソッドを定義している場合は、Laravelのフォームリクエストの新しい機能である「バリデーションのafter」を利用するために、このメソッドの名前を変更するか、修正する必要があります。Within
form
requests,
the
after
method
is
now
reserved
by
Laravel[https://github.com/laravel/framework/pull/46757].
If
your
form
requests
define
an
after
method,
the
method
should
be
renamed
or
modified
to
utilize
the
new
"after
validation"
feature
of
Laravel's
form
requests.
その他Miscellaneous
laravel/laravel
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.
GitHubのソース比較ツールで簡単に変更点を確認し、どのアップデートが自分にとって重要かを選択できます。ただし、GitHubソース比較ツールで表示される変更点の多くは、当オーガニゼーションがPHPネイティブ型を採用したことによるものです。これらの変更は後方互換性があり、Laravel 10への移行時に採用するかは任意です。You can easily view the changes with the GitHub comparison tool[https://github.com/laravel/laravel/compare/9.x...10.x] and choose which updates are important to you. However, many of the changes shown by the GitHub comparison tool are due to our organization's adoption of PHP native types. These changes are backwards compatible and the adoption of them during the migration to Laravel 10 is optional.