Laravel 10.25版本发布
Laravel / 管理员 发布于 1年前 336
本周,Laravel 团队发布了 v10.25,其中包括异常节流、Str::take() 方法等。本周,Laravel 进行了大量的修复、更新和错别字修正,社区对此一直表示感谢!
异常节流
Tim MacDonald 贡献了通过采样/限制异常报告速度来节流异常的能力。您的异常处理程序类可以定义一个 throttle() 方法,让您可以根据异常类型灵活地进行速率限制:
// App\Exceptions\Handler
use App\Exceptions\ApiMonitoringException;
use Illuminate\Broadcasting\BroadcastException;
use Illuminate\Cache\RateLimiting\Limit;
use Throwable;
/**
* Throttle incoming exceptions.
*/
protected function throttle(Throwable $e): mixed
{
return match (true) {
$e instanceof BroadcastException => Limit::perMinute(300),
$e instanceof ApiMonitoringException => Lottery::odds(1, 1000),
default => Limit::none(),
};
}
请注意,你可以返回一个限制值(Limit),用来限制日志记录的数量(在示例中为每分钟)、一个 Lottery 实例,或者干脆不返回任何内容(如果你想退出某个给定的异常类型)。
查看 Throttling Reported Exceptions 文档,开始在 Laravel 10.25 中使用异常节流。
https://laravel.com/docs/10.x/errors#throttling-reported-exceptions
字符串 take() 方法
Moshe Brodsky 为 Str 和 Stringable 提供了 take() 方法,当你想从第一个字符开始时,它是 substr() 的语法糖:
// Before
str('abcdef')->substr(0, 2) // 'ab'
Str::substr('abcdef', 0, 2); // 'ab'
// After
str('abcdef')->take(2) // 'ab'
Str::take('abcdef', 2); // 'ab'
您还可以从末尾取负数字符:
将 bcrypt 轮数增至 12
斯蒂芬-里斯-卡特(Stephen Rees-Carter)贡献了将 bcrypt 轮数从 10 增加到 12:
> PHP 正在将 bcrypt 的默认代价提高到 11 或 12,以跟上计算量的增长。
目前的默认值 10 是 PHP 11 年前设定的,现在已经不再合适了。
Hashcat 团队的一位成员证实,12 似乎是性能和安全性之间的最佳选择。
Symfony 使用 13 的成本,但这对某些服务器来说可能过高。
有关此更改的更多详情,请参阅 Pull Request #48494。
https://github.com/laravel/framework/pull/48494
版本说明
您可以在 GitHub 上查看以下新功能和更新的完整列表,以及 10.24.0 和 10.25.0 之间的差异。
以下版本说明直接来自更新日志:
https://github.com/laravel/framework/compare/v10.24.0...v10.25.0
https://github.com/laravel/framework/blob/cf4781c541ebee944ad4c991d6cd3c6ae1812290/CHANGELOG.md
v10.25.0
[10.x] 修正 EnumeratesValues::ensure() docblock 的 @return 标记中的键类型,
作者 @wimski,原文地址:https://github.com/laravel/framework/pull/48456
[10.x] 添加 str()->take($limit) 和 Str::take($string, $limit)
by @moshe-autoleadstar in https://github.com/laravel/framework/pull/48467
[10.x] 节流器异常,
由 @timacdonald 在 https://github.com/laravel/framework/pull/48391 提供。
[10.x] 由 @CalebDW 在 https://github.com/laravel/framework/pull/48420 中
提出的修复在混合使用 inline/block @php 指令时编译刀片失败的问题
[10.x] 由 @shawnlindstrom 在 https://github.com/laravel/framework/pull/48480 中
提出的修复可字符串位置的测试名称问题
[10.x] 由 @rmunate 在 https://github.com/laravel/framework/pull/48492
创建流畅方法 convertCase
[10.x] 修复 CanBeOneOfMany 产生错误结果的问题,
作者 @Guilhem-DELAITRE 发布于 https://github.com/laravel/framework/pull/47427
[10.x] 禁用不支持的列类型的自动递增功能,
作者 @ikari7789 发布于 https://github.com/laravel/framework/pull/48501
[10.x] 将 bcrypt 轮数增加到 12
由 @valorin 在 https://github.com/laravel/framework/pull/48494 提供
[10.x] 确保数组驱动程序的值在过期时间过期
(由 @timacdonald 在 https://github.com/laravel/framework/pull/48497 提供
[10.x] 修正错别字,
作者:@szepeviktor,原文地址:https://github.com/laravel/framework/pull/48513
[10.x] 改进 Arr::first 和 Arr::last 测试
@tamiroh 发表于 https://github.com/laravel/framework/pull/48511
[10.x] 为 MorphToMany 支点模型设置形态类型
by @gazben in https://github.com/laravel/framework/pull/48432
[10.x] 撤销在其他 *OrCreate 方法中使用 createOrFirst 的做法,
作者 @tonysm 发布于 https://github.com/laravel/framework/pull/48531
[10.x] 修正测试中的错字,
作者 @szepeviktor 发布于 https://github.com/laravel/framework/pull/48534
[10.x] 添加 HasManyThrough 关系上的 updateOrCreate 回归测试,
作者 @tonysm,载于 https://github.com/laravel/framework/pull/48533
[10.x] 将异常率限制转换为秒,
作者 @timacdonald 发布于 https://github.com/laravel/framework/pull/48543
[10.x] 为 HasManyThrough 关系添加 firstOrCreate 和 createOrFirst 方法,
作者 @tonysm 发布于 https://github.com/laravel/framework/pull/48541
[10.x] 缓存视图时处理自定义扩展
(由 @timacdonald 在 https://github.com/laravel/framework/pull/48524 提供
[10.x] 设置提示交互模式
(由 @jessarcher 在 https://github.com/laravel/framework/pull/48468 中提供
转:
https://laravel-news.com/laravel-10-25-0
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号