以每小时 20 美元的价格聘请具备人工智能专业知识的 Laravel 开发人员。48 小时内即可开始工作。

FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0

最后更新于 经过

FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0 image

Laravel 13.4 introduces a global strict mode for FormRequest that rejects input fields not declared in rules() , new queue facade methods for inspecting jobs by state, and full #[Delay] attribute support across the Bus Dispatcher and NotificationSender. It also includes validation rule fixes, Carbon overflow support, and several bug fixes.

  • FormRequest strict mode to reject undeclared input fields
  • Queue facade methods to inspect pending, delayed, and reserved jobs
  • #[Delay] attribute now works in Bus Dispatcher and NotificationSender
  • overflow option for plus and minus operations
  • Multiple validation rule fixes for null values and type errors

什么是新的

FormRequest Strict Mode

A new strict mode for FormRequest rejects any input field not explicitly declared in your rules() method. Laravel's form requests have always validated the 内容 of known fields, but silently ignored undeclared fields — meaning a client could send fields like is_admin 或者 role alongside a legitimate request without triggering a validation error.

Enable it globally from your AppServiceProvider :

使用 照亮\Foundation\Http\FormRequest ;
民众 功能 引导 () : 空白
{
表单请求 :: failOnUnknownFields 应用程序 () -> 是生产 ());
}

Or you can opt in per request class with the #[FailOnUnknownFields] 属性:

使用 Illuminate\Foundation\Http\Attributes\FailOnUnknownFields ;
#[ FailOnUnknownFields ]
班级 StoreUserRequest 延伸 表单请求
{
民众 功能 规则 () : 大批
{
返回 [
'姓名' => '必填|字符串' ,
'电子邮件' => '必填|电子邮件' ,
];
}
}

With strict mode enabled, sending an is_admin field alongside nameemail would fail validation. Individual request classes can opt out by setting the attribute to false :

#[ FailOnUnknownFields 错误的 )]
班级 WebhookRequest 延伸 表单请求
{
// Allows unknown fields even when global strict mode is on
}

The flag defaults to false , so existing behavior is unchanged unless you explicitly enable it.

拉取请求: #59430

Queue Job Inspection Methods

Three new methods on the Queue facade let you inspect jobs by state:

队列 :: 待处理职位 (); // jobs ready to be processed
队列 :: delayedJobs (); // jobs waiting for their delay to expire
队列 :: reservedJobs (); // jobs currently being processed by a worker

Each returns a CollectionInspectedJob 实例 uuid , name , attempts , 和 createdAt properties:

队列 :: reservedJobs 'high-priority' -> 第一的 () -> 姓名;
// => 'App\Jobs\SendEmail'
队列 :: 待处理职位 () -> 按计数 '姓名' (英文):
// => ['App\Jobs\SendEmail' => 1842, 'App\Jobs\ProcessOrder' => 43]

This is supported on the Database and Redis queue drivers. Other drivers return empty collections.

拉取请求: #59511

Delay Attribute Support Across Dispatchers

#[Delay] attribute introduced in v13.3.0 now works across all dispatchers. Previously, it was only wired into the Event Dispatcher — the Bus Dispatcher read the delay property directly, ignoring the attribute.

使用 Illuminate\Queue\Attributes\Delay ;
#[ Delay 30 )]
班级 ProcessInvoice 实现 应该排队
{
使用 可调度 , 可排队 ;
}
// Now correctly delayed by 30 seconds when dispatched via Bus or Notifications
ProcessInvoice :: 派遣 ();

拉取请求: #59514 , #59513

Carbon Overflow Option

新的 overflow option has been added to Carbon's plusminus methods, giving you control over how date arithmetic handles month-end boundaries. Here's a few examples from the pull request tests:

$carbon = :: 解析 '2026-01-31' (英文):
$this -> 断言相同 '2026-03-03' , $carbon -> 个月 : 1 , 溢出 : 真的 -> 日期字符串 ());
$carbon = :: 解析 '2026-01-31' (英文):
$this -> 断言相同 '2026-02-28' , $carbon -> 个月 : 1 , 溢出 : 错误的 -> 日期字符串 ());

拉取请求: #59509

其他修复和改进

Validation:

  • 固定的 TypeErrorstarts_with / ends_with rules on non-string values ( #59541
  • Fixed deprecation warnings in ContainsDoesntContain rules when values contain null ( #59561
  • Fixed deprecation warnings in InNotIn rules when values contain null ( #59576

队列和作业:

  • 修复了缺失 Illuminate\Queue\Attributes\Delay 属性 ( #59504
  • Fixed runtime property overrides ( onQueue ) taking precedence over class attributes ( #59468
  • 固定的 #[WithoutRelations] queue attribute not being inherited by child classes ( #59568

Models & Attributes:

  • 固定的 CollectedBy attribute not resolving through abstract parent classes ( #59488
  • Fixed static closure binding in remaining manager classes ( #59493

HTTP & Requests:

  • 固定的 $request->interval() failing with very small float values ( #59502
  • Fixed null redirect handling in unauthenticated exception handler ( #59505
  • Allow null to be passed directly to redirectGuestsTo()#59526

Strings:

  • 固定的 Str::markdown()Str::inlineMarkdown() crash on null input ( #59554

Security:

  • 额外 --ignore-scripts to yarn in install:broadcasting command ( #59494

其他:

  • 额外 pint.json to export-ignore ( #59497
  • Reverted SessionManager clone removal that caused duplicate Redis connections ( #59542

升级说明

No breaking changes are expected for typical applications. The new FormRequest::failOnUnknownFields() 默认为 false , so existing behavior is preserved. Review the full changelog for complete details when upgrading.

参考

保罗·雷德蒙德照片

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

归档于:
立方体

Laravel 时事通讯

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

图像
SerpApi

适用于您的 LLM 和 AI 应用的 Web 搜索 API

访问 SerpApi
Tinkerwell 徽标

廷克威尔

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

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

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

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

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

PhpStorm

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

PhpStorm
Laravel Cloud 标志

Laravel 云

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

Laravel 云
了解 Softtech 的标志

了解软科技

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

了解软科技
Kirschbaum 标志

樱桃树

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

樱桃树
Shift 标志

转移

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

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

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

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

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

幸运传媒

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

幸运传媒
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

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

SaaSykit:Laravel SaaS 入门套件
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
Laravel Starter Kits Now Include Toast Notifications image

Laravel Starter Kits Now Include Toast Notifications

阅读文章
Ship AI with Laravel: Stop Your AI Agent from Guessing image

Ship AI with Laravel: Stop Your AI Agent from Guessing

阅读文章
Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps image

Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps

阅读文章
Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions image

Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions

阅读文章
FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0 image

FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0

阅读文章
Pretty PHP Info: A Modern Replacement for `phpinfo()` image

Pretty PHP Info: A Modern Replacement for `phpinfo()`

阅读文章