Laravel 10.24 发布
本周,Laravel 团队发布了 v10.24,其中包括任务伪造更新、字符串位置助手、迁移表名称预测改进等功能。
虽然我们重点介绍了每个版本中的新功能,但是每周都有很多贡献者在改进框架。请查看发行说明以了解每周发布的完整更改,再次感谢所有为 Laravel 做出贡献的人。
以下是本周的最新动态一览:
允许伪造旧式任务
Tim MacDonald 贡献了一个更新,此更新允许推送旧式风格的队列任务:
旧式风格的队列任务推送(即引用任务类并将载荷通过数组格式传递)目前是不支持的。这项措施解决了以下问题::
Queue::fake([MyJob::class]);
Queue::push(MyJob::class, ['job' => 'payload']);
Queue::assertPushed(MyJob::class);
Str::substrPos() 方法介绍
Clemens Bastian 贡献了一个 substrPos()
方法,用其确定子字符串在字符串中第一次出现的位置. 它是对PHP中 mb_strpos 方法的封装:
// Str helper
Str::position('Hello, World!', 'W'); // 7
// Stringable
str('This is a test string.')->position('test'); // 10
// More examples
Str::position('This is a test string, test again.', 'test', 15); // 23
Str::position('Hello, World!', 'Hello'); // 0
Str::position('Hello, World!', 'World!'); // 7
Str::position('This is a tEsT string.', 'tEsT', 0, 'UTF-8'); // 10
Str::position('Hello, World!', 'W', -6); // 7
Str::position('Äpfel, Birnen und Kirschen', 'Kirschen', -10, 'UTF-8'); // 18
Str::position('@%€/=!"][$', '$', 0, 'UTF-8'); // 9
Str::position('Hello, World!', 'w', 0, 'UTF-8'); // false
Str::position('Hello, World!', 'X', 0, 'UTF-8'); // false
Str::position('', 'test'); // false
Str::position('Hello, World!', 'X'); // false
迁移任务中正确预测表名称
Islam Abdelfattah 改进了表名预测器功能(当用户创建迁移任务并修改已存在的数据库表列字段时)。当给定以下以to_users_table
结尾的命令时,该命令将为users
表创建正确的迁移任务:
php artisan make:migration \
add_is_sent_to_3rd_party_service_column_to_users_table
以上命令生成的迁移任务将在up/down
方法中自动包含以下代码:
Schema::table('users', function (Blueprint $table) {
//
});
发布说明
您可以在下面看到新特性和更新的完整列表,以及 GitHub 上 10.23.0 和 10.24.0 之间的区别。以下发布说明直接来自于变更日志:
v10.24.0
- 在查询生成器中使 join 方法的参数类型保持一致 by @melicerte 在 github.com/laravel/framework/pull/...
- [10.x] 修复视图后的文件竞争条件:缓存和 artisan up by @roxik 在 github.com/laravel/framework/pull/...
- [10.x] 重新启用 SQL Server CI by @GrahamCampbell 在 github.com/laravel/framework/pull/...
- 更新 request.stub by @olivsinz 在 github.com/laravel/framework/pull/...
- [10.x] phpdoc:Auth\Access\Response 构造函数允许空消息 by @snmatsui 在 github.com/laravel/framework/pull/...
- [10.x] 测试改进 by @crynobone 在 github.com/laravel/framework/pull/...
- 关闭 csrf_field 的自动完成功能 by @maxheckel 在 github.com/laravel/framework/pull/...
- [10.x] 删除 PHP 8.1 检查测试中是否包含枚举 by @Jubeki 在 github.com/laravel/framework/pull/...
- [10.x] 改进命名 by @timacdonald 在 github.com/laravel/framework/pull/...
- [10.x] 修复调用deleteDirectory时出现「文本文件忙」错误 by @ycs77 在 github.com/laravel/framework/pull/...
- 使用小数字键修复 Cache::many() by @AlexKarpan 在 github.com/laravel/framework/pull/...
- [10.x] 将操作/结帐从 v3 更新到 v4 by @tamiroh 在 github.com/laravel/framework/pull/...
lazyById
不会检查数据库响应中 id(别名)列的可用性,并且会默默地以无限循环结束,chunkById
可以 by @decadence 在 github.com/laravel/framework/pull/...- [10.x] 允许伪造旧作业 by @timacdonald 在 github.com/laravel/framework/pull/...
- [10.x] 引入
Str::substrPos
by @amacado 在 github.com/laravel/framework/pull/... - [10.x] 如果列的名称具有(「to」、「from」和/或「in」)术语,则在迁移中正确猜测表名称 by @i350 在 github.com/laravel/framework/pull/...
- [10.x] 重构 LazyCollection::take() 以节省内存 by @fuwasegu 在 github.com/laravel/framework/pull/...
- [10.x] 当默认值为枚举时获取值属性 by @squiaios 在 github.com/laravel/framework/pull/...
- [10.x] Composer 助手改进 by @crynobone 在 github.com/laravel/framework/pull/...
- [10.x] Symfony v6.4 测试 by @driesvints 在 github.com/laravel/framework/pull/...
本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。
好好好,在程序员节这天更新