Laravel 9.42, weekly updates, and 🔥 tip

Laravel 9.42

Lots of new features this week brings us to Laravel 9.42. Here are the highlights:

  • Add --rest option to queue:listen in 00a12e2
  • Add isUlid in Stringable in #45100
  • Add report_if and report_unless helpers in #45093
  • Set command description via AsCommand attribute in #45117
  • Add Route::singleton() in #44872

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 finished recording the videos for my upcoming Laracasts CreatorSeries. I started editing them over the weekend and hope to finish by the end of this week. We'll see, as editing is like 5x the work than record.

I also continued working on the Human Shifts. This is a busy time of year for them as a lot of teams slow down development, leaving a window to finally upgrade those old apps.

I'm also trying to bring down my task list as daughter v2 launches any day now. So I'm mostly focused on finishing the above. However, I am going to squeeze in a live stream this Wednesday to PR a --dirty option to Pint.

Finally, a friendly reminder that my Black Friday specials end Thursday. So you have about 36 hours left. These include significant discounts for my course bundles, as well as 30% off Workbench licenses and $400 off the Everything Plan.

🔥 Tip

One of the things I work on in my series is a class sorter. PHP comes with all sorts of helpful array sorting functions. In this case, I used usort to group methods within the class and customize their order.

This code can be done with a lot of if statements. But I stumbled upon a simple solution on StackOverflow. This defines the custom order as an array. Then you can use the indexes of the array to make the comparison.

// define the order
$order = ['__constructor', 'booting', 'boot', 'booted', ...];

For example, when comparing the __constructor method against the boot method, the __constructor index is 0 and boot is 2. Subtracting these indexes fulfills the comparison callback by returning a negative number when method a is less than method b, and a positive number when method b is greater than method a.