The Laravel team released 9.33 and 9.34, introducing Laravel Precognition, short attribute syntax for self-closing blade components, and more.
Note: we are also covering key new features released in Laravel 9.33, released last Friday between the typical weekly release.
Tim MacDonald contributed the introduction of Precognition. While a full explanation of out of the scope of this article, check out Pull Request #44339 for a deep description of what Precognition offers. In summary, here’s the TLDR:
Precognition is a new framework feature that will allow developers to create new and improved experiences for their users.
Precognition introduces a request / response header, middleware, and for some cases a global helper that Laravel reacts to in a unique manner.
When a Precognition request comes into Laravel, everything right up until the controller is executed. This includes all middleware, route model binding resolution, form request validation etc.
You should really read Pull Request #44339 to see examples of how you might utilize this exciting new feature!
Perry van der Meer contributed the short attribute syntax to self-closing blade components. This PR builds on the short attribute syntax released in Laravel 9.32 for Blade components:
<!-- current short syntax -->
<x-profile :$userId></x-profile>
<!-- short syntax for self-closing component -->
<x-profile :$userId/>
Nuno Maduro contributed Blade rendering support for backed enums. Take the following route view example:
// routes/web.php
Route::get('/', function () {
return view('dashboard', ['role' => UserRoles:: ADMIN]);
});
Given the $role
variable, it will be rendered properly in Blade now:
Hello, {{ $role }}.
<!-- ❌ Before: TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string -->
<!-- ✅ After: Hello, Admin. -->
Adrian Nürnberger contributed the missing cc()
method to mail fakes. The implementation is as follows:
public function cc($users)
{
return (new PendingMailFake($this))->cc($users);
}
Jae Toole contributed case-insensitive support to Stringable contains()
and containsAll()
methods:
// returns true
$this->stringable('taylor')
->contains(['LOR'], true);
// returns true
$this->stringable('taylor otwell')
->containsAll(['TAYLOR', 'OTWELL'], true);
You can see the complete list of new features and updates below and the diff between 9.33.0 and 9.34.0 on GitHub. The following release notes are directly from the changelog:
Illuminate/Database/Schema/ForeignIdColumnDefinition::constrained()
(#44425)Illuminate/Support/Testing/Fakes/MailFake::cc()
(#44319)Illuminate/Routing/Route::flushController()
(#44386)Illuminate/Filesystem/FilesystemAdapter::url()
with config prefix
(#44330)Source: Laravel News