Laravel 10.37 发布
Laravel 团队发布了 v10.37,提供了多个新能力:在 DynamoDB 中存储批量 metadata,在一个字段中断言多个错误,等。
批量存储到 DynamoDB 中
Sebastien Armand 贡献了在 DynamoDB (而非关联数据库)中存储批量元信息。您可以使用 queue.php
配置文件中的以下配置将应用配置为使用 DynamoDB:
'batching' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'dynamodb'),
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => 'job_batches',
],
断言多个错误信息
Tim MacDonald 贡献了使用 assertInvalid()
方法断言一个字段中的错误列表:
// Before, separate assertion calls are required
$response->assertInvalid(['email' => 'The email field must be a string.']);
$response->assertInvalid(['email' => 'The email field must be at least 5 characters.']);
// As of Laravel 10.37 you can now do:
$response->assertInvalid([
'email' => [
'The email field must be a string.',
'The email field must be at least 5 characters.',
],
]);
添加 engine() 方法到 Blueprint
James Brooks 贡献了一个 engine()
用来定义迁移 schema:
// Previously
Schema::table('foo', function (Blueprint $table) {
$table->engine = 'InnoDB';
// ...
});
// Using the new engine() method
Schema::table('foo', function (Blueprint $table) {
$table->engine('InnoDB');
// ...
});
获取表格的索引和外键
Hafez Divandari 贡献了 getIndexes()
和 getForeignKeys
方法,用以获取给定表格 schema 中的索引和外键:
Schema::getIndexes();
Schema::getForeignKeys();
getIndexes()
放回一个带有多个键的数组,如 name、columns、type、 unique 和 primary,而 getForeignKeys()
方法返回外键数组,其键包括 name, columns, foreign_schema, foreign_table, foreign_columns, on_update 和 on_delete。
Release notes
You can see the complete list of new features and updates below and the diff between 10.35.0 and 10.37.0 on GitHub. The following release notes are directly from the changelog:
v10.37.0
- [10.x] Add engine method to Blueprint by @jbrooksuk in https://github.com/laravel/framework/pull/49250
- [10.x] Use translator from validator in Can and Enum rules by @fancyweb in https://github.com/laravel/framework/pull/49251
- [10.x] Get indexes of a table by @hafezdivandari in https://github.com/laravel/framework/pull/49204
- [10.x] Filesystem : can lock file on append of content by @StephaneBour in https://github.com/laravel/framework/pull/49262
- [10.x] Test Improvements by @crynobone in https://github.com/laravel/framework/pull/49266
- [10.x] Fixes generating facades documentation shouldn't be affected by php-psr extension by @crynobone in https://github.com/laravel/framework/pull/49268
- [10.x] Fixes AboutCommand::format() docblock by @crynobone in https://github.com/laravel/framework/pull/49274
- [10.x] Route::getController() should return null when the accessing closure based route by @crynobone in https://github.com/laravel/framework/pull/49269
- [10.x] Add "noActionOnUpdate" method in Illuminate/Database/Schema/ForeignKeyDefinition by @hrsa in https://github.com/laravel/framework/pull/49297
- [10.x] Fixing number helper for floating 0.0 by @mr-punyapal in https://github.com/laravel/framework/pull/49277
- [10.x] Allow checking if lock succesfully restored by @Joostb in https://github.com/laravel/framework/pull/49272
- [10.x] Enable DynamoDB as a backend for Job Batches by @khepin in https://github.com/laravel/framework/pull/49169
- [10.x] Removed deprecated and not used argument by @Muetze42 in https://github.com/laravel/framework/pull/49304
- [10.x] Add Conditionable to Batched and Chained jobs by @bretto36 in https://github.com/laravel/framework/pull/49310
- [10.x] Include partitioned tables on PostgreSQL when retrieving tables by @hafezdivandari in https://github.com/laravel/framework/pull/49326
- [10.x] Allow to pass Arrayable or Stringble in rules In and NotIn by @michaelnabil230 in https://github.com/laravel/framework/pull/49055
- [10.x] Display error message if json_encode() fails by @aimeos in https://github.com/laravel/framework/pull/48856
- [10.x] Allow error list per field by @timacdonald in https://github.com/laravel/framework/pull/49309
- [10.x] Get foreign keys of a table by @hafezdivandari in https://github.com/laravel/framework/pull/49264
- [10.x] PHPStan Improvements by @crynobone in https://github.com/laravel/framework/pull/49343
- [10.x] Handle missing translations: more robust handling of callback return value by @DeanWunder in https://github.com/laravel/framework/pull/49341