Laravel 8.20, weekly updates, and 🔥 tip

Laravel 8.20

Lots of little fixes this week as well as a few new methods. So we get a minor version bump to 8.20.0.

  • Add custom registerDBALTypes to DatabaseServiceProvider in a5761d4
  • Ability to specify a separate lock connection in #35621
  • Add syncWithPivotDefaults method in #35644
  • Fix assertCookieExpired and assertCookieNotExpired checks for session cookies in #35637
  • Account for a numerical array of views in renderForAssertions in #35662
  • Catch DecryptException with invalid X-XSRF-TOKEN in #35671
  • Clear cached user in RequestGuard if a request changed in #35692

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.

Important Change

A few weeks back Laravel uncommented the TrustHosts middleware. This change has since been reverted. Apparently it was causing a 404 Not Found response for applications where the domain differed from the request. For example, vanity domains, misconfiguration, or redirection behind a load balancer.

While you may not have been affected, you may want to comment this out in your Http/Kernel.php unless you have reviewed and configured this middleware.

Weekly Journal

Some minor tweaks to Shift last week and a few pairing sessions. But mostly just organizing and planning for 2021. December is the slowest month for Shift. Which is fine as it allows me to take a little time off for the holidays.

Speaking of December, tomorrow (12/23) marks the 5 year anniversary of launching Shift. I plan to publish the home page facelift, and may write a quick retrospective if I have time. I'll share both on Twitter.

🔥 Tip {#tip}While working on CI last week, I ended up taking a deep dive into the precedence of app configuration when run Laravel tests. There are a few important nuances. One of which took me a few hours to figure out. You may review my write-up for full details, but I'll share the main gotcha now.

The <server> elements within PHPUnit's configuration are not overwritten by system environment variables. In fact, short of setting configuration in code, the <server> element has the highest precedence when running Laravel tests. This meant the values output in my CI environment were not being used.

Instead of using the <server> element, I used the <env> element. Doing so allowed the PHPUnit configuration to be used locally, but overwrite them in my CI environment with system variables. In learning this, I'm surprised Laravel uses the <server> elements within the default phpunit.xml configuration.