Laravel 12.50, weekly updates, and weekly tip
Laravel 12.50
Taylor was heading back Laracon India this week, so we had another travel delay on Laravel 12.50. Here are the highlights:
- Allow queued Listeners to be unique in #58402
- Use
morphMapwhen serializing model identifiers in #58482 - Add
authority()toUriin #58534 - Add
withoutAppends()toModelin #58552 - Add
hasMany()method toCollectionin #58550 - Add typed "getter" methods on
Cachein #58451 - Add
clamp()toRequestin #58608
You may review the full branch diff on GitHub for a complete list of changes.
Weekly Journal
Last week I tweaked the Livewire Shifts. Some more things were added to the Livewire 4 Upgrade Guide. So, in turn, I updated the automation for the Livewire 4.x Shift. I also implemented some feedback on the MFC Converter.
I'm continuing to work on the Livewire 3.x Shift. While there is an internal tool available, I think Shift can do a slightly better job by automating the entire process. Or at least provide a better user experience. In addition, it rounds out the catalog for Livewire Shifts.
After that, I made some tweaks to the new Laravel Cloud Readiness Shift. That name is a bit of a mouthful. I may change it back to the Laravel Cloud PreCheck.
Anyway, I launched it today on Laravel's Livestream. It checks your application for compatibility with Laravel Cloud. I partnered with Laravel to build this. So it is free to run. But I do provide an affiliate link if you find it helpful in deciding to migrate to Laravel Cloud.
Over the weekend I saw the first announcement of upcoming changes in Laravel 13. Taylor specifically mentioned the adoption of PHP attributes. So I promptly cut a new branch for l13 and began automating this refactor. While I do expect Laravel 13 to continue the "no breaking changes" theme, there are always things to automate. Especially since Shift's goal is to make your application feel like it has always been running the latest version.
Weekly Tip
I like memoizing variables within calculation methods. Traditionally, I have done this by declaring the variable static. While this is a built-in way, it has drawbacks. Specifically around "resetting" its value. This often appears during testing when classes are never released.
For those reasons, I either don't use static and recalculate or I create a setter so I can reset the value. Both are not ideal.
However, last week I was reminded of Laravel's once helper. While this is readily available in your Laravel app, it may also be added via illuminate/support.
Much like the Cache methods, once takes a callback which performs an (expensive) operation and returns a value. Internally, it tracks calls so the callback is only called once. This tracking allows once to reset in a more sane way than static.