Laravel 9.11, weekly updates, and 🔥 tip

Laravel 9.11

Looks like Laravel ended up tagging a release last week on Wednesday instead of Tuesday. As well as a patch release Thursday. Combined with today's release it brings us to Laravel 9.11.

Here are some highlights from both:

  • Add the ability to use alias when performing upsert via MySQL in #42053
  • Add beforeRefreshingDatabase callback to the RefreshDatabase trait in #42073
  • Add doesntExpectOutputToContain assertion in #42096
  • Add findOr to Eloquent in #42092
  • Support 'IS' and 'IS NOT' PostgreSQL operators in #42123
  • Add string to Illuminate/Http/Request in c9d34b7
  • Add methods to append and prepend jobs to existing chain in #42138
  • Add has and missing to ValidatedInput in #42184
  • Add join to Arr class in #42197
  • Accept nested objects in Arr::forget() in #42142
  • Add incrementQuietly and decrementQuietly database methods in #42132

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.

Weekly Journal

Last week I began updating the Laravel Fixer, Upgrade Checker, and Tests Generator to require Laravel 9 as a minimum. It's a bit more work than I thought. So I'll continue on that this week.

I also met with a copywriter to review Shift's home page. She helped point out some inconsistent wording and areas to emphasize.

I also added the demo video to the page. But realized it has the previous design. So I'll likely work to refresh that this week as well.

Finally, a few Human Shifts came in. I finished one yesterday taking an application from Laravel 6.x to Laravel 9.x. The other I'll be upgrading from Laravel 5.5 to Laravel 6.x.

🔥 Tip

Within the Shift codebase I create rather complex objects. For example, a custom syntax parser. Often this parser may or may not get used depending on if any instances of code were found.

To optimize this, I use memoization. A common memoization method in PHP might be:

public function finder()
{
static $finder;
 
if (is_null($finder)) {
$finder = new NikicParser(new CustomFinder());
}
 
return $finder;
}

Since 7.4, you may use null coalesce assignment to refactor this if statement:

public function finder()
{
static $finder;
 
$finder ??= new NikicParser(new CustomFinder());
 
return $finder;
}