Laravel 9.34 Released

Published on by

Laravel 9.34 Released image

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)
Paul Redmond photo

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

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Oh Dear

Oh Dear is the best all-in-one monitoring tool for all your Laravel apps.

Visit Oh Dear
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
LoadForge logo

LoadForge

Easy, affordable load testing and stress tests for websites, APIs and databases.

LoadForge
Paragraph logo

Paragraph

Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Paragraph
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. Partner with Lucky Media, your favorite Laravel Development Agency!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Oh Dear logo

Oh Dear

Oh Dear is the best all-in-one monitoring tool for all your Laravel apps.

Oh Dear
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell

The latest

View all →
FrankenPHP v1.0 is Here image

FrankenPHP v1.0 is Here

Read article
Self-healing URLs in Laravel image

Self-healing URLs in Laravel

Read article
Laravel 10.35 Released image

Laravel 10.35 Released

Read article
Solve n+1 queries in PHP with Scout APM image

Solve n+1 queries in PHP with Scout APM

Read article
Show Outdated Composer Dependencies in Laravel Pulse image

Show Outdated Composer Dependencies in Laravel Pulse

Read article
Announcing Laravel Pulse - A New Performance Monitoring Tool for Laravel Apps image

Announcing Laravel Pulse - A New Performance Monitoring Tool for Laravel Apps

Read article