Laravel Cloud 来了!为 Laravel 应用提供零配置的托管基础​​设施。 立即部署

Generate HTML Password Rules Attribute in Laravel 13.9.0

发布日期 经过

Generate HTML Password Rules Attribute in Laravel 13.9.0 image

Laravel v13.9.0 adds Password::toPasswordRulesString() for generating HTML passwordrules attributes so browsers and password managers can suggest compliant passwords automatically, along with Cloud queue metrics, optional disk storage for large SQS payloads, and more:

  • Password::toPasswordRulesString() for HTML passwordrules 属性
  • Cloud queue metrics for job processing telemetry
  • Optional disk storage for large SQS queue payloads
  • Concurrency::run() timeout support
  • PendingDispatch conditionable with when()unless()
  • PreparesForDispatch interface for pre-dispatch job hooks
  • foreignUuidFor schema blueprint helper
  • ThrottlesExceptions backoff now accepts a Closure
  • Enum support for contextual attribute binding

什么是新的

Password::toPasswordRulesString()

Password validation rule now has a toPasswordRulesString() method that converts a Password instance into a passwordrules attribute string for HTML inputs.

passwordrules 属性是 a specification introduced by Apple that lets browsers and password managers — including Safari, 1Password, and Bitwarden — read an app's password constraints and generate a valid password automatically, rather than the user having to trial-and-error a suggested password against validation errors.

每个 Password method maps to a specific rule token:

Password 方法 passwordrules 令牌
min(n) minlength: n
max(n) maxlength: n
letters() required: lower
mixedCase() required: lower; required: upper
numbers() required: digit
symbols() required: special

uncompromised() has no passwordrules equivalent and is not included in the output.

Here are the outputs for common combinations, verified against the merged tests:

密码 :: 分钟 8 -> toPasswordRulesString ();
// 'minlength: 8;'
密码 :: 分钟 8 -> 最大限度 64 -> toPasswordRulesString ();
// 'minlength: 8; maxlength: 64;'
密码 :: 分钟 8 -> 字母 () -> toPasswordRulesString ();
// 'minlength: 8; required: lower;'
密码 :: 分钟 8 -> 大小写混合 () -> toPasswordRulesString ();
// 'minlength: 8; required: lower; required: upper;'
密码 :: 分钟 12 -> 最大限度 64 -> 大小写混合 () -> 数字 () -> 符号 () -> toPasswordRulesString ();
// 'minlength: 12; maxlength: 64; required: lower; required: upper; required: digit; required: special;'

The most practical use is pairing it with Password::defaults() so the same policy you define in AppServiceProvider drives both server-side validation and the browser's password suggestions:

// 应用程序/提供商/AppServiceProvider.php
密码 :: 默认值 fn () => 密码 :: 分钟 12 -> 最大限度 64 -> 大小写混合 () -> 数字 () -> 符号 ());
< 输入
类型 = “密码”
自动完成 = "new-password"
passwordrules = {{ 密码 :: 默认值 () -> toPasswordRulesString () }}
/>

When a user focuses the field in a supporting browser or password manager, they'll be offered a generated password that already satisfies your rules — no back-and-forth with validation errors.

公关稿: #60070 经过 @imliam

Cloud Queue Metrics

Three PRs from @蒂麦克唐纳 add metrics tracking for Laravel Cloud queue connections. The new Illuminate\Foundation\Cloud\Queue decorator wraps any queue driver and emits events through a socket when jobs are queued and when processing starts and finishes. This gives Laravel Cloud visibility into job throughput, processing duration, and worker activity.

Config caching is also now supported for Cloud queues — prefix and suffix values are read from the config file rather than environment variables directly, making php artisan config:cache work correctly in Cloud deployments.

PR: #60074 , #60078 , #60094

Optional Disk Storage for Large SQS Payloads

SQS has a maximum message size of 1 MB. When a serialized job payload exceeds that limit, AWS rejects it with an InvalidParameterValue error. This release adds a built-in solution: an extended_store_options block in the SQS queue connection config that offloads large payloads to a filesystem disk (such as S3) and sends a small pointer through SQS instead. Workers fetch the full payload from disk when processing the job.

// config/queue.php
'平方' => [
// ...existing config...
'extended_store_options' => [
‘已启用’ => 环境 'SQS_STORE_ENABLED' , 错误的 ),
'磁盘' => 环境 'SQS_STORE_DISK' , 's3' ),
'前缀' => 环境 'SQS_STORE_PREFIX' , “” ),
'always' => 错误的 ,
'cleanup' => 真的 ,
],
],
  • enabled — turn the feature on or off (defaults to false
  • disk — which filesystem disk to store payloads on
  • prefix — path prefix for stored payload files on the disk
  • always — when true , stores every payload to disk regardless of size
  • cleanup — when true , deletes the disk file after the job is successfully processed

This is opt-in and backwards compatible. Existing SQS users are unaffected unless they set enabledtrue

公关稿: #59734 经过 @Orrison

Concurrency::run() Timeout Support

Concurrency::run() uses the process driver by default, which runs each task through Laravel's process layer. That layer has a default 60-second timeout, but there was no way to customize it from Concurrency::run() . A new timeout parameter is now available for the process driver:

并发 :: 跑步 ([
fn () => longRunningTask (),
], 暂停 : 300 (英文):

The fork driver is unchanged because spatie/fork does not support task timeouts. The sync driver also keeps its existing behavior since it runs tasks inline.

公关稿: #60105 经过 @dbpolito

PendingDispatch 可条件性

PendingDispatch now implements the Conditionable trait, which adds when()unless() methods. This lets you configure dispatched jobs inline without wrapping the dispatch call in conditionals:

SendPersonalDetailsToFraudDetectionTool :: 派遣 ($customer)
-> 什么时候 ($customer -> hasSufficientPersonalDetails (), fn ($job) => $job -> 毫不拖延 ());
SendPersonalDetailsToFraudDetectionTool :: 派遣 ($customer)
-> 除非 ($customer -> hasSufficientPersonalDetails (), fn ($job) => $job -> 延迟 180 ));

公关稿: #60047 经过 @kevinb1989

PreparesForDispatch 界面

新的 PreparesForDispatch interface adds a prepareForDispatch() method that runs before a job is pushed to the queue. The method can return false to cancel the dispatch entirely. This is useful for jobs dispatched from multiple call sites that all need the same pre-dispatch logic — for example, deduplicating IDs or checking whether a job is still needed before consuming queue capacity:

使用 Illuminate\Contracts\Queue\PreparesForDispatch ;
班级 SyncPodcastsJob 实现 应该排队 , PreparesForDispatch
{
使用 可排队 ;
民众 功能 __构造 民众 大批 $podcastIds) {}
民众 功能 prepareForDispatch () : 布尔值
{
$this -> podcastIds = array_unique $this -> podcastIds);
返回 数数 $this -> podcastIds) > 0 ;
}
民众 功能 处理 () : 空白
{
// ...
}
}

公关稿: #59879 经过 @jackbayliss

foreignUuidFor Schema Helper

新的 foreignUuidFor() method on schema blueprints provides an explicit API for migrations that want a UUID foreign key column. While the existing foreignIdFor() already handles UUID-backed models by detecting the key type, foreignUuidFor() makes the intent clear and mirrors the same model-aware behavior:

$表 -> foreignUuidFor 用户 ::班级 -> 受限制 ();

The helper infers the column name, related table name, and referenced primary key column from the model.

公关稿: #60091 经过 @Tresor-Kasenda

ThrottlesExceptions Backoff Accepts a Closure

backoff() 方法 ThrottlesExceptions middleware now accepts a Closure that receives the throwable. This is useful when the exception carries retry timing information — such as a Retry-After header from an external API — and you want to use it directly rather than a fixed backoff value:

新的 限制异常 maxAttempts : 10 , decaySeconds : 300 ))
-> byJob ()
-> 什么时候 fn 可抛出 $e) => $e 实例 ExternalAPIException && $e -> isRateLimited ())
-> 退避 fn 可抛出 $e) => $e 实例 ExternalAPIException
$e -> retryAfter () / 60
: 2
),

公关稿: #60103 经过 @cosmastech

Enum Support for Contextual Attribute Binding

#[Auth] , #[Authenticated] , 和 #[Cache] contextual attributes now accept both UnitEnum and backed enum values in addition to strings. This lets you use enum cases to reference guards and cache stores in dependency injection:

使用 App\Enums\AuthGuard ;
使用 Illuminate\Container\Attributes\Auth ;
民众 功能 __构造
#[ 授权 AuthGuard :: 行政 )]
受保护 警卫 $adminGuard,
){}

公关稿: #60092 经过 @Tresor-Kasenda

其他修复和改进

  • Scoped filesystem Cloud supportStorage::cloud() now works with scoped disks ( #60030 经过 @jeremynikolic
  • Migration event namesMigrationStartedMigrationEnded events now include the migration name ( #60059 经过 @jackbayliss
  • Worker timeout exit code override — The worker timeout exit code can now be customized via WORKER_TIMEOUT_EXIT_CODE , matching the existing WORKER_MEMORY_EXIT_CODE behavior ( #60072 经过 @jackbayliss
  • Guzzle PSR-7 multipart fix — Nested multipart array expansion now relies on guzzlehttp/psr7 to fix a serialization issue ( #59984 经过 @RomainMazB
  • Generic paginate return typesBuilder paginate methods now have generic return types for better IDE support ( #60045 经过 @levikl
  • Lottery reset on teardownLottery is now reset during test case teardown to prevent test bleed ( #60083 经过 @cosmastech
  • AWS credential provider fix — Custom AWS credential providers now work correctly with the queue driver ( #60000 经过 @iWader
  • Unicode regex fixes — Unicode modifiers added to preg_splitSeeInHtml whitespace normalization ( #60056 , #60090

参考

保罗·雷德蒙德照片

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

归档于:
立方体

Laravel 时事通讯

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

图像
Laravel 代码审查

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

访问 Laravel 代码审查
Lucky Media 标志

幸运传媒

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

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

SaaSykit:Laravel SaaS 入门套件

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

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

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

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

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

PhpStorm

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

PhpStorm
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
Laravel Cloud 标志

Laravel 云

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

Laravel 云
Tinkerwell 徽标

廷克威尔

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

廷克威尔
了解 Softtech 的标志

了解软科技

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

了解软科技
Kirschbaum 标志

樱桃树

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

樱桃树
Shift 标志

转移

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

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

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

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

Harpoon:新一代时间跟踪和发票系统
DHH Joins Laravel Live Denmark 2026 for Fireside Chat with Taylor Otwell image

DHH Joins Laravel Live Denmark 2026 for Fireside Chat with Taylor Otwell

阅读文章
Model-Based Scheduling for Laravel with Cadence image

Model-Based Scheduling for Laravel with Cadence

阅读文章
Laravel's AI SDK adds sub-agents image

Laravel's AI SDK adds sub-agents

阅读文章
Laravel Introduces First-Party Passkey Authentication Support image

Laravel Introduces First-Party Passkey Authentication Support

阅读文章
Scrollbar Styling and Container Size Utilities in Tailwind CSS v4.3.0 image

Scrollbar Styling and Container Size Utilities in Tailwind CSS v4.3.0

阅读文章
Attach Addresses to Any Eloquent Model with Laravel Addressable image

Attach Addresses to Any Eloquent Model with Laravel Addressable

阅读文章