侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

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'

您还可以从末尾取负数字符:

laravel str.png


将 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

  • 上一条:
    在go语言中实现生成文件的校验和功能代码示例
    下一条:
    适用于 Laravel 的表单请求测试程序包
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • Laravel 11.14版本发布 - 新的字符串助手和ServeCommand改进(0个评论)
    • Laravel 11.12版本发布 - Artisan的`make`命令自动剪切`.php `扩展(0个评论)
    • Laravel的轻量型购物车扩展包:binafy/laravel-cart(0个评论)
    • Laravel 11.11版本发布 - 查看模型中的第三方关系:show(0个评论)
    • 近期文章
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-07
    • 2017-08
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-08
    • 2020-09
    • 2020-10
    • 2020-11
    • 2021-01
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-04
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-02
    • 2024-03
    • 2024-04
    • 2024-05
    • 2024-06
    • 2024-07
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客