Laravel 10.42 Released
This week, the Laravel team released v10.42 with global default options for the HTTP client, a max validation rule for the password rule object, a string unwrap helper, and more.
Global Default Options for the HTTP Client
Tim MacDonald contributed the ability to configure global default options for the HTTP client via a service provider:
Http::globalOptions([
'timeout' => 5,
'connect_timeout' => 2,
])
If you call the globalOptions
method more than once, it will override the original global configuration on subsequent calls.
String Unwrap Helper
Steve Bauman contributed a Str::unwrap()
method which you can use to unwrap strings:
// Unquote
Str::unwrap('"Unquote"', '"');
// `Unquote`
// some: "json"
Str::unwrap('{ some: "json" }', '{', '}');
// ` some: "json" `
Add Multiple Channels/Routes to at Once
D. Nagy Gergő contributed the ability to configure multiple routes at once for on-demand notifications:
NotificationFacade::routes([
'mail' => ['example@test.local' => 'Test Customer'],
'vonage' => '+3620123456',
])->notify(new OrderStatusChanged($order));
New JobQueueing Event
Daniel Mason contributed a JobQueueing
event to the framework that is fired before a job is sent to the queue provider. Here’s a rough example of where this event is instantiated, which includes the $connectionName
, $job
, and $payload
:
use Illuminate\Queue\Events\JobQueueing;
new JobQueueing($this->connectionName, $job, $payload));
Max Validation Rule for Passwords
Jeremy Angele contributed a max length validation rule to the Password rule object. This is useful when defining a default password rule:
// Before
Password::min(8)->rules('max:32');
// New max() method
Password::min(8)->max(32);
Release notes
You can see the complete list of new features and updates below and the diff between 10.41.0 and 10.42.0 on GitHub. The following release notes are directly from the changelog