Laravel 7.18 发布

Laravel

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() (#33315b718d3a)
  • 新增 ComponentAttributeBag 支持 Macroable (#33354)
  • 新增 filter 、 whereStartsWith 和  thatStartWith 到 Illuminate\View\ComponentAttributeBag (0abe2db07ee3e8)
  • 新增 Illuminate\Database\Eloquent\Collection::toQuery() (#3335615586fa)
  • 新增 first() 方法到 Illuminate\View\ComponentAttributeBag (#33358731b94f)
  • 新增 everyTwoMinutes() | everyThreeMinutes() | everyFourMinutes() 方法到 Illuminate/Console/Scheduling/ManagesFrequencies (#33379)

修复

  • 修复 ConfigurationUrlParser query 解码 (#33340)
  • 修复 Illuminate\Database\Eloquent\Relations\Concerns\AsPivot::delete() (#33347)

变更

  • 替换验证器中的点和星号的占位符 (#33367)
本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。

原文地址:https://laravel-news.com/laravel-7-18-re...

译文地址:https://learnku.com/laravel/t/47041

本文为协同翻译文章,如您发现瑕疵请点击「改进」按钮提交优化建议
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!