Get expert guidance in a few days with a Laravel code review

Laravel 8.16 Released

Published on by

Laravel 8.16 Released image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

The Laravel team released 8.16 last week with an artisan command to take you directly to a database CLI, an excellent progress bar convenience method, and a new Ably broadcaster implementation.

This release was jam-packed with awesome new features, so let’s check out the latest changes in the 8.x branch:

With Progress Bar Convenience Method

Taylor Otwell contributed the withProgressBar() convenience method you can use in console commands. Here’s what you might do to create a progress bar straight from the docs:

$users = App\Models\User::all();
$bar = $this->output->createProgressBar(count($users));
 
$bar->start();
 
foreach ($users as $user) {
$this->performTask($user);
 
$bar->advance();
}
 
$bar->finish();

With this convenience method, it could look like this:

$users = App\Models\User::all();
 
$this->withProgressBar($users, function ($user, $bar) {
$this->performTask($user);
});

Call Silently

Taylor Otwell contributed a callSilently() method which is an alias to callSilent in the CallsCommands trait. You might find that this reads more clearly:

$this->callSilently('config:cache');

Release Unique Job Locks Before Processing

Paras Malhotra contributed the ability to release unique job locks before the job processes. The new interface is useful for scenarios where a race condition could exist between job completion and unlocking. To learn more, I’d suggest checking out Pull Request #35255 to the framework and the documentation pull request.

Ably Broadcaster

Taylor Otwell contributed an AblyBroadcaster for broadcasting real-time, live-updating user interfaces. Developers can now pick from Pusher, Redis, and Ably for real-time communication needs. For a refresher, check out the Broadcasting documentation on how you can get started broadcasting in your Laravel projects.

Support Delaying Notifications Per Channel

Gergő D. Nagy contributed the ability to delay notification delivery on a per-channel basis instead of one overall delay. Defining delays per channel is useful if you need to delay the same notification differently for email, database, SMS, etc., notifications. You may now optionally call delay() with an associative array of channels you’d like to delay:

$user->notify((new InvoicePaid($invoice))->delay([
'mail' => now()->addMinutes(5),
'sms' => now()->addMinutes(10),
]));

Note that a channel not defined in the array will not have a delay when using the array format.

Allow Array Sorting By Multiple Criteria

johnylemon contributed a sortByMany method to the Arr support class, which will sort props in ascending order by default:

$sorted = Arr::sortByMany($unsorted, [
'name', 'age'
];
 
$sorted = Arr::sortByMany($unsorted, [
['name', false], // will be ordered by `name` descending
['age', true] // then by age ascending, if there are items with same `name` value
];

Lastly, the PR outlines complex sorting using closures:

$sorted = Arr::sortByMany($unsorted, [
// order by childrens count asc
function($a, $b) {
return $a->childrens()->count() <=> $b->childrens()->count();
},
// then by grandchildrens by descending order if needed
function($a, $b) {
return $b->grandchildrens()->count() <=> $a->grandchildrens()->count();
}
];

Drop Into a Database CLI

Paras Malhotra—who has been contributing a lot of excellent queue features lately—contributed a new artisan command to drop into a database CLI:

php artisan db mysql

The above command will use the database credentials to connect to a MySQL CLI prompt without manually remembering/alias commands. This command should work with mysql, pgsql, sqlite, and sqlsrv.

Collections splitIn Method

Andrew Brown contributed the splitIn method, which is similar to split. The distinct difference is that split makes it so that each chunk never differs in count from another chunk by more than one. Conversely, splitIn will fill all earlier chunks before allocating the remainder to the final chunk. The pull request has further details on why you might use splitIn if you’d like to learn more.

Release Notes

You can see the full list of new features and updates below and the diff between 8.15.0 and 8.16.0 on GitHub. The following release notes are directly from the changelog:

v8.16.0

Added

  • Added Illuminate\Console\Concerns\InteractsWithIO::withProgressBar() (4e52a60, 169fd2b)
  • Added Illuminate\Console\Concerns\CallsCommands::callSilently() as alias for callSilent() (7f3101b, 0294433)
  • Added option to release unique job locks before processing (#35255, b53f13e)
  • Added ably broadcaster (e0f3f8e, 6381aa9)
  • Added ability to define table name as default morph type (#35257)
  • Allow overriding the MySQL server version for database queue driver (#35263)
  • Added Illuminate\Foundation\Testing\Wormhole::back() (#35261)
  • Support delaying notifications per channel (#35273)
  • Allow sorting on multiple criteria (#35277, 53eb307)
  • Added Illuminate/Database/Console/DbCommand.php command (#35304, b559b3e)
  • Added Collections splitIn methods (#35295)

Fixed

  • Fixed rendering of notifications with config custom theme (325a335)
  • Fixing BroadcastException message in PusherBroadcaster@broadcast (#35290)
  • Fixed generic DetectsLostConnection string (#35323)
  • Fixed SQL Server command generation (#35317)
  • Fixed route model binding on cached closure routes (eb3e262)

Changed

  • Disable CSRF on broadcast route (acb4b77)
  • Easily set a null cache driver (#35262)
  • Updated aws/aws-sdk-php suggest to ^3.155 (#35267)
  • Ensure ShouldBeUniqueUntilProcessing job lock is released once (#35270)
  • Rename qualifyColumn to qualifyPivotColumn in BelongsToMany & MorphToMany (#35276)
  • Check if AsPivot trait is used instead of Pivot Model in Illuminate\Database\Eloquent\Relations\BelongsToMany (#35271)
  • Avoid no-op database query in Model::destroy() with empty ids (#35294)
  • Use –no-owner and –no-acl with pg_restore (#35309)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Laravel Mobile Pass: Generate Apple Wallet and Google Wallet Passes image

Laravel Mobile Pass: Generate Apple Wallet and Google Wallet Passes

Read article
PHPverse 2026 Returns June 9th image

PHPverse 2026 Returns June 9th

Read article
LLPhant: A PHP Generative AI Framework Inspired by LangChain image

LLPhant: A PHP Generative AI Framework Inspired by LangChain

Read article
Debounceable Queued Jobs in Laravel 13.6.0 image

Debounceable Queued Jobs in Laravel 13.6.0

Read article
Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB image

Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB

Read article
Laravel API Starter Kits Are Coming Soon! image

Laravel API Starter Kits Are Coming Soon!

Read article