本篇文章给大家带来了关于laravel的相关知识,Laravel团队发布了 9.5 版本,其中包括部分队列伪造,freezeTime()辅助函数,存储assertDirectoryEmpty()断言等等,希望对大家有帮助。
【相关推荐:laravel视频】
Laravel 团队发布了 9.5 版本,其中包括部分队列伪造,freezeTime () 辅助函数,存储 assertDirectoryEmpty () 断言,assertJsonPath () 中的闭包等:
对集合 Implode 方法的回调支持
@Lito 贡献了在 Collect::implode() 上的回调支持, 以简化 ->map()->implode() 调用:
// 之前<br/>{{ $user->cities->map(fn ($city) => $city->name.' ('.$city->state->name.')')->implode(', ') }}<br/>// 使用回调 <br/>{{ $user->cities->implode(fn ($city) => $city->name.' ('.$city->state->name.')', ', ') }}<br/>
使用 Storage Fake 断言一个空目录
Mark Beech 贡献了使用 Storage::fake () 实例断言空目录的能力:
// 9.5 版本之前<br/>$this->assertEmpty(Storage::disk('temp')->allFiles('/foo'));<br/>// +9.5<br/>Storage::disk('temp')->assertDirectoryEmpty('/foo');<br/>
如果目录中没有文件,只有其他子目录,则断言将失败,因为它包含其他文件夹 / 文件。这里有一个来自 pull request discussion 的例子:
Storage::fake('temp');<br/>Storage::disk('temp')->put('/foo/bar.txt', 'string');<br/>Storage::disk('temp')->assertDirectoryEmpty('/'); // 失败<br/>
JSON 断言 “assertJsonPath ()” 现在接受闭包
Fabien Villepinte 贡献了将闭包传递给 assertJsonPath 的,没有任何向后兼容的中断的能力:
$response = TestResponse::fromBaseResponse(new Response([<br/> 'data' => ['foo' => 'bar'],<br/>]));<br/>$response->assertJsonPath('data.foo', 'bar');<br/>$response->assertJsonPath('data.foo', fn ($value) => $value === 'bar');<br/>
虽然上面的示例使用字符串版本似乎更简单,但如果你需要围绕路径断言更复杂的逻辑,你现在可以使用闭包。
部分队列伪造
Taylor Otwell 为测试中的队列贡献了部分伪造:
Queue::fake([JobsToFake::class, /* ... */]);<br/>
创建 “through” 模型的新方法
Hafez Divandari 贡献了不需要覆盖整个 hasOneThrough 或者 hasManyThrough 方法而创建一个新的 “through” 模型的能力:
// Define a `newThroughInstance` method<br/>protected function newThroughInstance($resource)<br/>{<br/> return (new \App\Models\ExampleEntity)->setTable($resource);<br/>}<br/>
新的字符串换行的辅助函数
Markus Hebenstreit 贡献了 wrap() 字符串辅助函数。 这里有一个来自 pull request description 的示例用法:
Str:wrap('value')->wrap('"');<br/>Str::of('value')->wrap('"');<br/>str('value')->wrap('"');<br/>// 输出: "value"<br/>Str:wrap('is', 'This ', ' me!');<br/>Str::of('is')->wrap('This ', ' me!');<br/>str('is')->wrap('This ', ' me!');<br/>// 输出: This is me!<br/>
用于测试的 Freeze Time 辅助函数
@Italo 贡献了 freezeTime() 辅助函数 —— 一个将在测试中冻结当前时间的测试方法:
public function test_something()<br/>{<br/> $this->freezeTime();<br/> // 或将时间设置为日期的当前秒<br/> // 没有亚秒级精度。<br/> $this->freezeSecond();<br/>}<br/>
freezeTime() 方法是以下内容的语法糖:
$this->travelTo(Carbon::now());<br/>
允许在 Http::beforeSending () 中接受可调用对象
Dries Vints 有助于在 Http::beforeSending() 方法中接受可调用对象,而不仅仅是可调用的类。 现在,以下示例将起作用,而不是获取 “调用数组上的成员函数 __invoke ()”:
Http::baseUrl('https://api.example.org')<br/> ->beforeSending([ $this, 'prepareRequest' ])<br/> ->asJson()<br/> ->withoutVerifying();<br/>
发行说明
你可以在下面查看新功能和更新的完整列表以及在 GitHub 上查 9.4.0 和 9.5.0 之间的差异 。 以下发行说明直接来自 changelog:
9.5.0 版本
新增
增加了对 implode 集合方法的回调支持。(#41405)
增加了 Illuminate/Filesystem/FilesystemAdapter::assertDirectoryEmpty()。 (#41398)
为 SesTransport 实施邮件 “元数据”。 (#41422)
使 assertPath () 接受闭包。(#41409)
增加了部分队列伪造。(#41425)
为 schedule:test 命令添加了 –name 选项。 (#41439)
定义了 Illuminate/Database/Eloquent/Concerns/HasRelationships::newRelatedThroughInstance()。(#41444)
增加了 Illuminate/Support/Stringable::wrap() (#41455)
为测试增加了 “freezeTime” 辅助函数。(#41460)
允许在 Illuminate/Http/Client/PendingRequest.php::runBeforeSendingCallbacks() 中使用 beforeSending 调用。(#41489)
修复
修复了在过滤名称或域时来自 route:list 的弃用警告。 (#41421)
修复了当 URL 返回空状态码时的 HTTP::pool 响应。 (#41412)
修复了 Illuminate/Session/Middleware/AuthenticateSession.php 中的 recaller 名称解析。(#41429)
修复了在 /Illuminate/Session/Middleware/AuthenticateSession.php 中被使用的 guard 实例 (#41447)
修复了 route:list –except-vendor,用于隐藏 Route::view () & Route::redirect () (#41465)
改变
在 \Illuminate\Database\Eloquent\Factories\Factory 中为连接属性添加空类型。(#41418)
更新了 GeneratorCommand 中的保留名称 (#41441)
重新设计了 php artisan schedule:list 命令。 (#41445)
扩展了 eloquent 高阶代理属性。(#41449)
允许传递已经命名的参数给动态的本地作用域。(#41478)
如果标签通过但在 Illuminate/Encryption/Encrypter.php 中不受支持,则抛出异常。(#41479)
当 composer vendor 文件夹不在项目的文件夹时 为案例更新 PackageManifest::$vendorPath 初始化。(#41463)
【相关推荐:laravel视频教程】
以上是归纳Laravel 9.5版本的新增、修复和改变!的详细内容。更多信息请关注PHP中文网其他相关文章!

Tocombatisolationandlonelinessinremotework,companiesshouldimplementregular,meaningfulinteractions,provideequalgrowthopportunities,andusetechnologyeffectively.1)Fostergenuineconnectionsthroughvirtualcoffeebreaksandpersonalsharing.2)Ensureremoteworkers

laravelispularfullull-stackDevelopmentBecapeitOffersAsAseAseAseAseBlendOfbackendEdpoperandPowerandForterFlexibility.1)ITSbackEndCapaPabilities,sightifyDatabaseInteractions.2)thebladeTemplatingEngingEngineAllolowsLows

选择视频会议平台的关键因素包括用户界面、安全性和功能。1)用户界面应直观,如Zoom。2)安全性需重视,MicrosoftTeams提供端到端加密。3)功能需匹配需求,GoogleMeet适合简短会议,CiscoWebex提供高级协作工具。

最新版本的Laravel10与MySQL5.7及以上、PostgreSQL9.6及以上、SQLite3.8.8及以上、SQLServer2017及以上兼容。这些版本选择是因为它们支持Laravel的ORM功能,如MySQL5.7的JSON数据类型,提升了查询和存储效率。

laravelisanexceltentchoiceforfull-stackdevelopmentduetoitsRobustFeaturesAndEsofuse.1)ITSImplifiesComplexComplextaskSwithitSmodernphpsyNtaxandToolSandToolSlikeBlikeforFront-Endandeloquentormquentormquentormforback-end.2)

Laravel10,releasedonFebruary7,2023,isthelatestversion.Itfeatures:1)Improvederrorhandlingwithanewreportmethodintheexceptionhandler,2)EnhancedsupportforPHP8.1featureslikeenums,and3)AnewLaravel\Promptspackageforinteractivecommand-lineprompts.

thelatestlaravelververversionenhancesdevelopmentwith:1)简化的inimpliticmodelbinding,2)增强EnhancedeloquentcapabibilitionswithNewqueryMethods和3)改善了supportorfortormodernphpfortornphpforternphpfeatureserslikenamedargenamedArgonedArgonsemandArgoctess,makecodingMoreftermeforefterMealiteFficeAndEnjoyaigaigaigaigaigaiganigaborabilyaboipaigyAndenjoyaigobyabory。

你可以在laravel.com/docs找到最新Laravel版本的发布说明。1)发布说明提供了新功能、错误修复和改进的详细信息。2)它们包含示例和解释,帮助理解新功能的应用。3)注意新功能的潜在复杂性和向后兼容性问题。4)定期审查发布说明可以保持更新并激发创新。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

Atom编辑器mac版下载
最流行的的开源编辑器