MWAN MOBILE

×
mwan_logo
blog-banner

Laravel 9.34 Released

Programming 26-Oct-2022

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:

<!-- current short syntax -->
<x-profile :$userId></x-profile>
 
<!-- short syntax for self-closing component -->
<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:

// 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. -->

Add cc() method to MailFake (9.33)

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);
}

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

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);

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)

Source: Laravel News