Laravel 8.34, weekly updates, and πŸ”₯ tip

Laravel 8.34

A patch release last week and a lot of new features this week brings us to Laravel 8.34.0.

Here are the highlights:

  • Add DB::resetRecordsModifications in #36617
  • Add --without-path option to route:list in #36619
  • Adjust fluent JSON Assertions in #36620
  • Add timestamp to schedule:work output in #36621
  • Add assertion to verify type of key in JSON in #36638
  • Add prohibited validation rule in #36667
  • Add strict comparison to distinct validation rule in #36669
  • Add lazy() and lazyById() Query Builder methods in #36699

You may review the full branch diff on GitHub for a complete list of changes.

This minor 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.

Weekly Journal

Last week I took a bit of a break to watch Laracon Online. Lots of good talks. Most notably Taylor's demonstration of the new Octane package.

I'm pretty interested in this one. I've always thought about improving Laravel's view cache. I think with Octane things like static page caches and even something within Blade like @esi (edge side includes) would be possible. So I'm excited to take a peek when Taylor releases the beta.

I took Thursday off as well. It was a rough start to the day with a few deploy mistakes and bugs. So I felt I would do less damage banging around in the garage.

I came back strong Friday by squashing several of the outstanding Shift bugs. As well as implementing some feedback I received from the new Tailwind Shifts.

The conference and day away from code also gave me time to think about the next project for Shift. I started toying with an idea and spent a few minutes over the weekend seeing if it would be possible. I have a few more things I'd like to check, but it seems like it could work…

This week I'm building a Tailwind Linter. This will initially scan the Tailwind configuration file for default values and opportunities to leverage the extend option. This will be a free Shift in an effort to build awareness around the new Tailwind Shifts.

I also have more Human Shifts which came in, so I'll spend most of this week working on those. Then hopefully have some time at the end of the week to continue spiking on the new idea.

πŸ”₯ Tip

Something I noticed during Laracon Online and have seen from Human Shifts is setting the request object in the Controller constructor.

PHP 8 makes this super clean with the new constructor property promotion. For example, you may write:

php public function __construct( public Request $request ) {}

Now, you may be thinking this is the πŸ”₯ tip, but it's not. In fact, quite the opposite.

Laravel's lifecycle changed way back in the early days of Laravel 5. Since then a controller may be instantiated very early when loading the application. For example, by the router.

However, at this point, things may not be fully hydrated. For example, the request object. Most notably it's missing session and authentication data.

So, while you may simply assign the request to a property, be mindful not to actually use the request for anything within the constructor.

This is yet another reason I prefer to use the request object which Laravel automatically injects into controller actions.