Laravel 9.35, weekly updates, and 🔥 tip
New features this week brings us to Laravel 9.35. Here are the highlights:
- Allow loading trashed models for resource routes in #44405
Model::preventAccessingMissingAttributes()option in #44283
- Correct channel matching in #44531
- Allow short tags for mail components in #44527
- Use controller middleware without resolving controller in #44516
- Introduce alternative mailable syntax in #44462
You may review the full branch diff on GitHub for a complete list of changes.
This version bump and update is automated for subscribers to a Shifty Plan. If you don't have one of those, be sure to bump your constraint and run
composer update to get the latest features.
Last Wednesday I started a new live stream series for October (Hacktober). My focus this month will be working on Blueprint. In the last live stream I reviewed the open PR's. Tomorrow I'll work through the open issues.
I also had another Human Shift come in to upgrade a Laravel 5.8 application. I worked on that Wednesday and Thursday. As always, I took any opportunities along the way to tweak the PR comments and improve Shift's automation.
These days the biggest remaining manual upgrade step are packages updates. While I'll never be able to upgrade all packages within an application, I've started to upgrade some of the first-party Laravel packages.
So Friday, I added automation to the Laravel 9.x Shift to add a migration for Sanctum 3.0 as it is the only upgrade step. I hope to do something similar for future versions of Cashier.
Over the weekend and yesterday, I started working on the Mid Shift. This is a special Shift for subscribers to a Shifty Plan. Now that Laravel has moved to annual release cycles, there are a lot of changes to core files during that year. Although new features are non-breaking, some of them require these core file changes.
So, this Mid Shift ensures your core files are up-to-date. Much like any other Shift, subscribers receive an automated PR with nice atomic commits and comments for any manual changes you might need to make.
I hope to run that tomorrow for subscribers with projects already upgraded to Laravel 9.x. Of course, all of these changes are also in the Laravel 9.x Shift. So if you ran that today, it'd upgrade all the core files to their latest version.
While the collection methods within Laravel are awesome, for simple cases, such as filtering an array, I still reach for PHP's native functions.
However, something that's nice about the collection methods is it passes both the value and key to the callback.
By default, PHP only passes the value. But many of these function have a flag which allows you to specify the arguments.
For example, to just pass the keys to the callback for
array_filter($dependencies,fn ($package) => str_starts_with($package, 'laravel/'),ARRAY_FILTER_USE_KEY);