This week, the Laravel team released v11.38, which includes a fluent Email
validation rule, the ability to retrieve a form request or fluent value as an array, a finally() pipeline method, and more.
Fluent Email Validation Rule
Sander Muller contributed a fluent Email
rule to "provide a similar experience as the Password and File validation rules."
// Before$request->validate([ 'email' => ['required', 'string', 'email', 'strict', 'dns'],]); // After$request->validate([ 'email' => ['required', 'string', Rule::email()->strict()->dns()],]);
See Pull Request #54067 for details.
Add array() Method to FormRequest and Fluent
Steve Bauman contributed an array()
method to cast a value from a form request object or Fluent instance:
$fluent = new Fluent(['email' => 'test@example.com']); $fluent->array('email'); // ['test@example.com'] // ?email=test@example.com$request->array('email'); // ['test@example.com']
See Pull Request #54177 for details.
Add a finally() Method to Pipeline
Nuno Maduro contributed a finally()
method that can specify a callback to be executed regardless of a pipeline's outcome.
// Beforetry { $result = Pipeline::send($deployment) ->through([PipeOne::class, PipeTwo::class]) // one of the pipes does not call the $next or throws an exception... ->then(fn () => $deployment->deploy());} finally { // perform clean up...} // After$result = Pipeline::send($deployment) ->through([PipeOne::class, PipeTwo::class]) // one of the pipes does not call the $next or throws an exception... ->finally(fn () => /** perform clean up */) ->then(fn () => $deployment->deploy());
See Pull Request #54110 for details.
Add --except Flag to the Artisan Optimize Commands
Jon Erickson contributed an --except
option to skip commands when running optimizations. This new option allows you to include partial keys and a comma-separated list of command names to exclude:
# Skip by command namephp artisan optimize --except route:cache # Skip by keyphp artisan optimize --except route # Skip by comma delimited list of keys or command namesphp artisan optimize:clear --except route,view:cache
Filter Routes by Action in route:list
@miccehedin contributed the --action
option to find routes using a specific action string:
route:list --action=TestController
Release notes
You can see the complete list of new features and updates below and the diff between 11.37.0 and 11.38.0 on GitHub. The following release notes are directly from the changelog:
v11.38.0
- Fix offset range in docblock by @simon-tma in https://github.com/laravel/framework/pull/54062
- [11.x] Fix breaking change in
RefreshDatabase
by @SjorsO in https://github.com/laravel/framework/pull/54075 - [11.x] Fallback to parent methods on
HasUniqueStringIds
trait by @hafezdivandari in https://github.com/laravel/framework/pull/54096 - [11.x] Adds
finally
method to pipeline helper by @nunomaduro in https://github.com/laravel/framework/pull/54110 - Add support for missing Postgres connection options by @Maniload in https://github.com/laravel/framework/pull/54101
- fix: Don't set newLineWritten to true unless verbosity allows output by @ConnySjoblom in https://github.com/laravel/framework/pull/54127
- [11.x] Adds support for Attribute return mutators to the
Eloquent/Builder
pluck method by @MattBradleyDev in https://github.com/laravel/framework/pull/54130 - [11.x] Fixes wrong
@mixin
onSoftDeletes
trait by @nunomaduro in https://github.com/laravel/framework/pull/54140 - [11.x] Replace string class names with ::class constants by @panakour in https://github.com/laravel/framework/pull/54134
- [11.x] fix
times()
calls by @browner12 in https://github.com/laravel/framework/pull/54141 - [11.x] minor readability by @browner12 in https://github.com/laravel/framework/pull/54117
- Handles factory=null in ConnectException while recording request-response in PendingRequest by @StSarc in https://github.com/laravel/framework/pull/54121
- [11.x] Refine error messages for detecting lost connections (Debian bookworm compatibility) by @mfn in https://github.com/laravel/framework/pull/54111
- [11.x] fix: filter vendor paths from registered loaders in Application::inferBasePath by @calebdw in https://github.com/laravel/framework/pull/54119
- [11.x] Allow exceptions to the
optimize
andoptimize:clear
commands by @jonerickson in https://github.com/laravel/framework/pull/54070 - Add action filter to route:list by @miccehedin in https://github.com/laravel/framework/pull/54135
- No explicit
USE database
statement by @TheLevti in https://github.com/laravel/framework/pull/54132 - Add support for custom payloads and channels in broadcasting by @JanneDeVos in https://github.com/laravel/framework/pull/54099
- [11.x] Add fluent
Email
validation rule by @SanderMuller in https://github.com/laravel/framework/pull/54067 - [11.x] middleware support for specific method in resource routes by @MrPunyapal in https://github.com/laravel/framework/pull/53313
- [11.x] Support DB aggregate by group (new methods) by @GromNaN in https://github.com/laravel/framework/pull/53679
- Correct return type to match functionality by @willpower232 in https://github.com/laravel/framework/pull/54148
- [11.x] Renaming Traveler to Passable and Stops to Pipes by @mathiasgrimm in https://github.com/laravel/framework/pull/54142
- [11.x] Add
Dispatchable::newPendingDispatch()
by @cosmastech in https://github.com/laravel/framework/pull/54153 - [11.x] Add
FormRequest::array($key)
andFluent::array($key)
by @stevebauman in https://github.com/laravel/framework/pull/54177 - [11.x] Make methods of
HasRelationships
generic by @SanderMuller in https://github.com/laravel/framework/pull/54174 - [11.x] Make tests pass on Herd by @SanderMuller in https://github.com/laravel/framework/pull/54171
- Revert "Fix: Handle mixed-type values in compileInsert" by @crynobone in https://github.com/laravel/framework/pull/54169
- [11.x] Fix docblock for
PendingDispatch@getJob()
by @cosmastech in https://github.com/laravel/framework/pull/54158 - pass options to migration events by @willpower232 in https://github.com/laravel/framework/pull/54151
- Encode cache values for SQLite with base64 to prevent failing on \0 characters by @adamkiss in https://github.com/laravel/framework/pull/54178
- [11.x] Fix invokable validation rule return type by @axlon in https://github.com/laravel/framework/pull/54179