影響度の高い変更High Impact Changes
- 依存パッケージの更新Updating Dependencies[#updating-dependencies]
- LaravelインストーラのアップデートUpdating the Laravel Installer[#updating-the-laravel-installer]
影響度が中程度の変更Medium Impact Changes
- モデルとUUIDv7Models and UUIDv7[#models-and-uuidv7]
影響度の低い変更Low Impact Changes
- Carbon3Carbon 3[#carbon-3]
- 並列処理結果のインデックスマッピングConcurrency Result Index Mapping[#concurrency-result-index-mapping]
- ImageバリデーションからSVGを除外Image Validation Now Excludes SVGs[#image-validation]
- 複数スキーマのデータベース調査Multi-Schema Database Inspecting[#multi-schema-database-inspecting]
- リクエストのネストした配列のマージNested Array Request Merging[#nested-array-request-merging]
11.xから12.0へのアップグレードUpgrading To 12.0 From 11.x
アップグレード見積もり時間:5分Estimated Upgrade Time: 5 Minutes
Laravel Shift を使用すると、アプリケーションのアップグレードを自動化できます。[!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.
Note: 私たちは、互換性のない変更を可能な限りすべて文書化するよう努力しています。これらの互換性のない変更の一部はフレームワークの不明瞭な部分であり、こうした変更の一部が実際にあなたのアプリケーションに影響を与える可能性があります。時間を節約したいですか?
依存パッケージのアップデートUpdating Dependencies
影響の可能性: 高いLikelihood Of Impact: High
アプリケーションのcomposer.json
ファイルにある、以下の依存パッケージを更新してください。You should update the following dependencies in your application's composer.json
file:
laravel/framework
を^12.0
へlaravel/framework
to^12.0
phpunit/phpunit
を^11.0
へphpunit/phpunit
to^11.0
pestphp/pest
を^3.0
へpestphp/pest
to^3.0
Carbon3Carbon 3
影響の可能性: 低いLikelihood Of Impact: Low
Carbon2.xのサポートを削除しました。すべてのLaravel 12アプリケーションはCarbon 3.xを必須にしました。Support for Carbon 2.x[https://carbon.nesbot.com/docs/] has been removed. All Laravel 12 applications now require Carbon 3.x[https://carbon.nesbot.com/docs/#api-carbon-3].
LaravelインストーラのアップデートUpdating the Laravel Installer
新しいLaravelアプリケーションを作成するためにLaravelインストーラCLIツールを使用している場合は、Laravel12.xと新しいLaravelスターターキットに対応するため、インストーラを更新する必要があります。composer global require
でLaravelインストーラをインストールした場合は、composer global update
でインストーラを更新してください。If you are using the Laravel installer CLI tool to create new Laravel applications, you should update your installer installation to be compatible with Laravel 12.x and the new Laravel starter kits[https://laravel.com/starter-kits]. If you installed the Laravel installer via composer global require
, you may update the installer using composer global update
:
composer global update laravel/installer
PHPとLaravelをphp.new
でインストールしている場合は、お使いのオペレーティングシステムにあったphp.new
インストールコマンドを再実行するだけで、最新バージョンのPHPとLaravelインストーラをインストールすることができます:If you originally installed PHP and Laravel via php.new
, you may simply re-run the php.new
installation commands for your operating system to install the latest version of PHP and the Laravel installer:
/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)"
# 管理者として実行
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))
/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
または、Laravel HerdバンドルのLaravelインストーラを使用している場合は、Herdインストールを最新リリースへ更新してください。Or, if you are using Laravel Herd's[https://herd.laravel.com] bundled copy of the Laravel installer, you should update your Herd installation to the latest release.
並列処理Concurrency
並列処理結果のインデックスマッピングConcurrency Result Index Mapping
影響の可能性: 低いLikelihood Of Impact: Low
連想配列を用い、Concurrency::run
メソッドを呼び出すと、並行処理の結果を関連するキーと一緒に返すようになりました。When invoking the Concurrency::run
method with an associative array, the results of the concurrent operations are now returned with their associated keys:
$result = Concurrency::run([
'task-1' => fn () => 1 + 1,
'task-2' => fn () => 2 + 2,
]);
// ['task-1' => 2, 'task-2' => 4]
データベースDatabase
複数スキーマのデータベース調査Multi-Schema Database Inspecting
影響の可能性: 低いLikelihood Of Impact: Low
Schema::getTables()
、Schema::getViews()
、Schema::getTypes()
メソッドは、すべてのスキーマの結果をデフォルトで含むようになりました。引数へschema
を渡すと、指定したスキーマの結果のみを取得できます。The Schema::getTables()
, Schema::getViews()
, and Schema::getTypes()
methods now include the results from all schemas by default. You may pass the schema
argument to retrieve the result for the given schema only:
// 全スキーマの全テーブル
$tables = Schema::getTables();
// `main`スキーマの全テーブル
$table = Schema::getTables(schema: 'main');
// 'main'と'blog'スキーマの全テーブル
$table = Schema::getTables(schema: ['main', 'blog']);
Schema::getTableListing()
メソッドは、スキーマ修飾されたテーブル名をデフォルトで返すようになりました。必要に応じ、schemaQualified
引数を渡して動作を変更できます。The Schema::getTableListing()
method now returns schema-qualified table names by default. You may pass the schemaQualified
argument to change the behavior as desired:
$tables = Schema::getTableListing();
// ['main.migrations', 'main.users', 'blog.posts']
$table = Schema::getTableListing(schema: 'main');
// ['main.migrations', 'main.users']
$table = Schema::getTableListing(schema: 'main', schemaQualified: false);
// ['migrations', 'users']
db:table
とdb:show
コマンドは、PostgreSQLやSQL Serverと同様に、MySQL、MariaDB、SQLiteのすべてのスキーマの結果を出力するようになりました。The db:table
and db:show
commands now output the results of all schemas on MySQL, MariaDB, and SQLite, just like PostgreSQL and SQL Server.
EloquentEloquent
モデルとUUIDv7Models and UUIDv7
影響の可能性: 中程度Likelihood Of Impact: Medium
HasUuids
トレイトは、UUID仕様のバージョン7(順序付きUUID)と互換性のあるUUIDを返すようにしました。モデルのIDへ順序付きUUIDv4文字列を使い続けたい場合は、HasVersion4Uuids
traitを使用してください。The HasUuids
trait now returns UUIDs that are compatible with version 7 of the UUID spec (ordered UUIDs). If you would like to continue using ordered UUIDv4 strings for your model's IDs, you should now use the HasVersion4Uuids
trait:
use Illuminate\Database\Eloquent\Concerns\HasUuids; // [tl! remove]
use Illuminate\Database\Eloquent\Concerns\HasVersion4Uuids as HasUuids; // [tl! add]
HasVersion7Uuids
トレイトは削除しました。以前このトレイトを使用していた場合は、代わりにHasUuids
トレイトを使用してください。The HasVersion7Uuids
trait has been removed. If you were previously using this trait, you should use the HasUuids
trait instead, which now provides the same behavior.
リクエストRequests
リクエストのネストした配列のマージNested Array Request Merging
影響の可能性: 低いLikelihood Of Impact: Low
$request->mergeIfMissing()
メソッドは、「ドット」記法を使用してネストした配列データをマージできるようになりました。これまでこのメソッドに依存して「ドット」記法バージョンのキーを含むトップレベル配列キーを作成している場合は、この新しい挙動を考慮してアプリケーションを調整する必要があるかもしれません。The $request->mergeIfMissing()
method now allows merging nested array data using "dot" notation. If you were previously relying on this method to create a top-level array key containing the "dot" notation version of the key, you may need to adjust your application to account for this new behavior:
$request->mergeIfMissing([
'user.last_name' => 'Otwell',
]);
バリデーションValidation
ImageバリデーションからSVGを除外Image Validation Now Excludes SVGs
image
バリデーションルールは、デフォルトでSVG画像を許可しなくなりました。もし、image
ルールでSVGを許可したい場合は、明示的に許可する必要があります。The image
validation rule no longer allows SVG images by default. If you would like to allow SVGs when using the image
rule, you must explicitly allow them:
use Illuminate\Validation\Rules\File;
'photo' => 'required|image:allow_svg'
// もしくは
'photo' => ['required', File::image(allowSvg: true)],
その他Miscellaneous
さらに、laravel/laravel
のGitHubリポジトリの変更点をご覧になることをお勧めします。これらの変更の多くは必須ではありませんが、これらのファイルをあなたのアプリケーションへ同期させておくとよいでしょう。これらの変更の一部はこのアップグレードガイドでカバーしていますが、設定ファイルやコメントの変更など、他の変更はカバーしていません。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/11.x...12.x] and choose which updates are important to you.