Laravel 9.34 Released

News

October 5th, 2022

Laravel 9.34 Released

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.

Laravel Precognition (9.33)

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!

Short attribute syntax for self-closing blade components (9.34)

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:

1<!-- current short syntax -->
2<x-profile :$userId></x-profile>
3 
4<!-- short syntax for self-closing component -->
5<x-profile :$userId/>

Render PHP's "BackedEnum" in Blade views (9.34)

Nuno Maduro contributed Blade rendering support for backed enums. Take the following route view example:

1// routes/web.php
2Route::get('/', function () {
3 return view('dashboard', ['role' => UserRoles:: ADMIN]);
4});

Given the $role variable, it will be rendered properly in Blade now:

1Hello, {{ $role }}.
2 
3<!-- ❌ Before: TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string -->
4<!-- ✅ After: Hello, Admin. -->

Add cc() method to MailFake (9.33)

Adrian Nürnberger contributed the missing cc() method to mail fakes. The implementation is as follows:

1public function cc($users)
2{
3 return (new PendingMailFake($this))->cc($users);
4}

Ignore case in Stringable contains() and containsAll() (9.33)

Jae Toole contributed case-insensitive support to Stringable contains() and containsAll() methods:

1// returns true
2$this->stringable('taylor')
3 ->contains(['LOR'], true);
4 
5// returns true
6$this->stringable('taylor otwell')
7 ->containsAll(['TAYLOR', 'OTWELL'], true);

Release Notes

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:

v9.34.0

Added

  • Short attribute syntax for Self Closing Blade Components (#44413)
  • Adds support for PHP's BackedEnum to be "rendered" on blade views (#44445)

Fixed

  • Fixed Precognition headers for Symfony responses (#44424)
  • Allow to create databases with dots (#44436)
  • Fixes dd source on windows (#44451)

Changed

  • Adds error output to db command when missing host (#44394)
  • Changed Illuminate/Database/Schema/ForeignIdColumnDefinition::constrained() (#44425)
  • Allow maintenance mode events to be listened to in closure based listeners (#44417)
  • Allow factories to recycle multiple models of a given typ (#44328)
  • Improves dd clickable link on multiple editors and docker environments (#44406)

v9.33.0

Added

  • Added Illuminate/Support/Testing/Fakes/MailFake::cc() (#44319)
  • Added Ignore Case of Str::contains and Str::containsAll to Stringable contains and containsAll (#44369)
  • Added missing morphs methods for the ULID support (#44364)
  • Introduce Laravel Precognition (#44339)
  • Added Illuminate/Routing/Route::flushController() (#44386)

Fixed

  • Fixes memory leak on PHPUnit's Annotations registry (#44324, #44336)
  • Fixed Illuminate/Filesystem/FilesystemAdapter::url() with config prefix (#44330)
  • Fixed the "Implicit conversion from float to int loses precision" error in Timebox Class (#44357)

Changed

  • Improves dd source on compiled views (#44347)
  • Only prints source on dd calls from dump.php (#44367)
  • Ensures a Carbon version that supports PHP 8.2 (#44374)

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.