几天内即可获得 Laravel 代码审查方面的专家指导

Interruptible Jobs in Laravel 13.7.0

最后更新于 经过

Interruptible Jobs in Laravel 13.7.0 image

Laravel v13.7.0 introduces the Interruptible interface for queued jobs to respond to worker signals, a new @fonts Blade directive for Vite font optimization, bulk JSON path assertions for testing, SortDirection enum support in collections, and several other improvements across the framework.

  • Jobs can now react to worker signals via the Interruptible 界面
  • 新的 WorkerInterrupted event for observability
  • 新的 @fonts Blade directive and Vite font optimization runtime
  • Bulk JSON path assertions in TestResponse
  • SortDirection enum support for collections and Arr
  • Enum support for LazyCollection keyBy()
  • Various bug fixes and improvements

什么是新的

Jobs Can React to Worker Signals

Queued jobs can now implement the Interruptible interface to respond when a worker receives a signal like SIGTERM . This lets long-running jobs clean up or set a stop flag before the worker exits:

使用 Illuminate\Contracts\Queue\Interruptible ;
使用 照亮\合约\队列\应该队列 ;
使用 照亮\基金会\队列\可排队 ;
班级 ReportJob 实现 应该排队 , Interruptible
{
使用 可排队 ;
受保护 布尔值 $stop = 错误的 ;
民众 功能 处理 () : 空白
{
尽管 $this -> stop) {
// do work...
}
}
民众 功能 interrupted 整数 $signal) : 空白
{
$this -> 停止 = 真的 ;
}
}

公关稿: #59833

New @fonts Blade Directive and Vite Font Optimization

This release adds a new @fonts Blade directive and Vite::fonts() method for rendering font preload links and inline styles. The feature reads font manifests generated by the Vite plugin and supports selective family loading.

Basic usage in your layout:

文档类型 html >
< html >
< >
@fonts
@迅速地 'resources/js/app.js'
</ >
< 身体 >
{{ $slot }}
</ 身体 >
</ html >

This renders preload <link> tags and an inline <style> block with all @font-face rules and CSS variables from the font manifest.

You can also filter to load only specific font families:

{{-- Load a single family --}}
@fonts 'sans'
{{-- Load multiple families --}}
@fonts ([ 'sans' , 'mono' ])

公关稿: #59584

Bulk JSON Path Assertions in TestResponse

The testing layer now includes assertJsonPaths()assertJsonMissingPaths() methods for asserting multiple JSON values at once.

前:

$响应 -> assertJsonPath 'data.id' , 1
-> assertJsonPath 'data.name' , “泰勒”
-> assertJsonPath 'meta.count' , 3 (英文):

后:

$响应 -> assertJsonPaths ([
'data.id' => 1 ,
'data.name' => “泰勒” ,
'meta.count' => 3 ,
]);

The companion assertJsonMissingPaths() method works the same way for asserting absent keys:

$响应 -> assertJsonMissingPaths ([ '密码' , 'secret_token' ]);

公关稿: #59829

SortDirection Enum Support for Collections

Collections and the Arr class now support the SortDirection enum for specifying sort order, providing better type safety when sorting:

使用 SortDirection ;
$已排序 = $集合 -> sortBy '姓名' , descending : SortDirection :: Descending (英文):

公关稿: #59859

Introducing WorkerInterrupted Event

新的 WorkerInterrupted event is dispatched when a worker receives a signal, before it stops. This is useful for observability — you can log, alert, or call an external service when a signal arrives, even if the individual job doesn't implement Interruptible

公关稿: #59848

isLocked Method Added to Lock Class

The Lock class now includes an isLocked() method to check the current lock status.

公关稿: #59791

Enum Support for LazyCollection keyBy()

LazyCollection::keyBy() 现在接受一个 BackedEnum , matching the behavior already available in Collection . Previously, passing an enum would throw an error when attempting to convert it to a string.

公关稿: #59809

其他修复和改进

This update includes enum support improvements across ConcurrencyManager, QueueManager, LogManager, SessionManager, and RedisManager. Various docblock improvements, type corrections, and bug fixes from community contributors are also included.

升级说明

No breaking changes are expected for typical applications. Review the changelog for PR-by-PR details when upgrading.

参考

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

访问 Laravel Cloud
MongoDB 徽标

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Laravel Web Push Notifications image

Laravel Web Push Notifications

阅读文章
RedBerry to Host Georgia's First Laravel Meetup in Tbilisi image

RedBerry to Host Georgia's First Laravel Meetup in Tbilisi

阅读文章
A Free Shift to Check If Your App is Ready for Laravel Cloud image

A Free Shift to Check If Your App is Ready for Laravel Cloud

阅读文章
Laravel Idempotency: HTTP Idempotency Middleware for Laravel image

Laravel Idempotency: HTTP Idempotency Middleware for Laravel

阅读文章
Polyscope for Windows is Now Available image

Polyscope for Windows is Now Available

阅读文章
Laravel Sluggable image

Laravel Sluggable

阅读文章