Laravel 7.18 发布

Laravel团队发布了v7.18.0,其中包含了HTTP客户端中间件方法和视图组件属性更新,以及最新的新功能、修复程序,以及7.x分支中的变化:
HTTP withMiddleware
Hannes Van De Vreken 为框架的HTTP客户端贡献了withMiddleware方法。它使用Guzzle的处理程序堆栈将用户定义的中间件推送到堆栈:
$client = new \Illuminate\Http\Client\PendingRequest();
$debugBar = new \DebugBar\StandardDebugBar();
// 获取数据收集器。
$timeline = $debugBar->getCollector('time');
// 封装时间线
$profiler = new \GuzzleHttp\Profiling\Debugbar\Profiler($timeline);
// 添加中间件到处理程序堆栈
$client->withMiddleware(new \GuzzleHttp\Profiling\Middleware($profiler));
视图组件属性功能
Kevin McKee贡献了ComponentAttributeBag宏。如果您对这些好处感兴趣,我建议您查看Pull Request#33354,其中有详细信息。
与此 PR 一起,Taylor Otwell 贡献了更多的 ComponentAttributeBag 方法,包括 filter 方法,whereStartsWith方法和 thatStartWith方法(whereStartsWith方法的别名):
$this->assertSame('class="font-bold"', (string) $bag->whereStartsWith('class'));
Kevin 还贡献了 ComponentAttributeBag::first 方法用于从ComponentAttributeBag 实例获取第一个属性:
{{ $attributes->thatStartWith('wire:model')->first() }}
新增的定时任务频率
Sjors Ottjes 为调度程序提供了新的调度方法(通过 ManagesFrequencies trait),为一分钟,两分钟和三分钟的调度添加了一些语法糖:
// Before
$schedule->job(SyncSomething::class)->cron('*/2 * * * *'); // every 2 minutes
// After, new methods
$schedule->job(SyncSomething::class)->everyTwoMinutes();
// PR also adds everyThreeMinutes and everyFourMinutes
$schedule->job(SyncSomething::class)->everyThreeMinutes();
$schedule->job(SyncSomething::class)->everyFourMinutes();
发行日志
您可以在下面看到新功能和更新的完整列表以及[7.17.0和7.18.0] (https://github.com/laravel/framework/compare/v7.17.0...v7.18.0)之间的区别。
v7.18.0
新增
- 新增
Illuminate\Http\Client\PendingRequest::withMiddleware()(#33315, b718d3a) - 新增 ComponentAttributeBag 支持 Macroable (#33354)
- 新增
filter、whereStartsWith和thatStartWith到Illuminate\View\ComponentAttributeBag(0abe2db, 07ee3e8) - 新增
Illuminate\Database\Eloquent\Collection::toQuery()(#33356, 15586fa) - 新增
first()方法到Illuminate\View\ComponentAttributeBag(#33358, 731b94f) - 新增
everyTwoMinutes()|everyThreeMinutes()|everyFourMinutes()方法到Illuminate/Console/Scheduling/ManagesFrequencies(#33379)
修复
- 修复
ConfigurationUrlParserquery 解码 (#33340) - 修复
Illuminate\Database\Eloquent\Relations\Concerns\AsPivot::delete()(#33347)
变更
- 替换验证器中的点和星号的占位符 (#33367)
本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。
关于 LearnKu
推荐文章: