编程

Laravel 发布了 新版本 9.36

1257 2022-10-20 20:41:19

Laravel 团队发布了 新版本 9.36。包括使 blade 组件反应更快,一个内容响应断言,mailable 断言,等等

 

让 blade 模板反应更快 

Nuno Maduro 对 blade 组件性能进行了优化改进。建议查阅相关 PR #44487 查看详情描述。总体而言,有如下一些粗略的提升:

  • 匿名组件 — 提速高达 52% 
  • 视图类组件 - 提升高达 39% 
  • Inline 类组件 — 提速高达 92%
  • 动态组件 ( 渲染匿名组件 ) — 提速高达 72% 
  • 动态组件 ( 渲染 inline 类组件 ) — up to 83% faster

特别感谢 Nuno! Laravel forever!

Mailable 断言

Andrew Minion 贡献了 mailable 断言, 使邮件类测试变得容易:

$mailable = (new Mail())->build();
$mailable
    ->assertHasTo('user@example.com')
    ->assertHasCc('user@example.com')
    ->assertHasBcc('user@example.com')
    ->assertHasReplyTo('user@example.com')
    ->assertHasReplyTo('user@example.com')
    ->assertHasFrom('user@example.com')
    ->assertHasTag('test')
    ->assertHasMetadata('foo', 'bar');

TestResponse assertContent()

Tim MacDonald 贡献了一个叫 assertContent() 的方法,为响应内容的断言测试添加了一些语法糖:

// before...
$this->assertSame('foo bar', $response->content());
 
// after...
$response->assertContent('foo bar');

 为控制台警报添加冗长级别

Pavel Panzyga 贡献了指定警报冗长级别的能力。相关 PR 描绘了怎样使用该特性: 

$this->alert('Alert box only for debug mode', 'vvv');
$this->alert('Normal alert box');
$this->alert('Very important alert box', 'quiet');

 

v9.36.0

Added

  • Added mailable assertions (#44563)
  • Added Illuminate/Testing/TestResponse::assertContent() (#44580)
  • Added to Illuminate/Console/Concerns/InteractsWithIO::alert() $verbosity param (#44614)

Optimization

  • Makes blade components blazing fast (#44487)

Fixed

  • Fixed Illuminate/Filesystem/Filesystem::relativeLink() (#44519)
  • Fixed for model:show failing with models that have null timestamp columns (#44576)
  • Allow Model::shouldBeStrict(false) to disable "strict mode" (#44627)

Changed

  • Dont require a host for sqlite connections in php artisan db (#44585)
  • Let MustVerifyEmail to be used on models without id as primary key (#44613)
  • Changed Illuminate/Routing/Route::controllerMiddleware() (#44590)