Laravel 10.21: Unveiling Exciting New Features

LaravelCodeCraft
2 min readSep 3, 2023

--

Exciting news for Laravel fans! The Laravel team has released version 10.21, which includes a slew of new features and changes that will certainly raise your development game. Laravel continues to provide developers with tools to simplify complicated processes and enhance overall coding efficiency in this edition. Let’s have a look at the highlights of Laravel 10.21.

Mastering String Manipulation

Introducing Laravel Str::convertCase() Method

The introduction of the convertCase() method is one of the release’s standout features.This technique serves as a versatile wrapper over the mb_convert_case function, making it simple to manipulate strings while taking character encoding and multi-byte characters into account.

use Illuminate\Support\Str;

// Convert to uppercase, handling special characters gracefully.
$upper = Str::convertCase("Unlocking the Power of PHP!", MB_CASE_UPPER);

// Convert to lowercase, preserving special characters.
$lower = Str::convertCase("Unlocking the Power of PHP!", MB_CASE_LOWER);

// Convert to title case, capitalizing the first letter of each word.
$title = Str::convertCase("Unlocking the Power of PHP!", MB_CASE_TITLE);

You may manage case conversions with precision and elegance with the convertCase() function.

Broadcasting Made Even Better

Empower Notifications with broadcastAs() Method

The broadcastAs() method is added to the BroadcastNotificationCreated event. This update allows you to select custom broadcast event names, giving you more control over your notification broadcasts.

This update ensures that your events have a consistent naming convention and is quite useful, especially in larger systems with complex notification hierarchies.

Streamlined HTTP Requests

Enhanced PendingRequest::pool() Method

This focuses on making it easier for developers to work with HTTP requests. The improved pool() technique in the HTTP client provides a more intuitive and efficient solution.

use Illuminate\Support\Facades\Http;
use Illuminate\Http\Client\Pool;

$responses = Http::pool(fn (Pool $pool) => [
$pool->get('https://laravel.com'),
]);

return $responses[0]->body();

With this improvement, you should expect improved autocomplete support when interacting with pool responses.

Simplified String Modifications

Convenient String Helpers for Start and End Replacement

This offers us two useful string aids designed to make replacing or trimming values at the beginning or end of a string easier. These aids conduct replacements only if the provided value is present at the intended location.

Str::replaceEnd('/start', '/end', '/path/to/my/start/nested/start');
// /path/to/my/start/nested/end

Str::replaceStart('/start', '/end', '/start/path/to/my/start/nested/start');
// /end/path/to/my/start/nested/start

When dealing with string alterations, these string helpers simplify your code and improve readability.

Enhanced Job Management

Efficient Counting of Failed Job Instances

A more efficient method of counting failed task instances utilising failed job providers. This enhancement allows you to conduct a count query in the database, removing the requirement to retrieve all records and then count them.

Here’s an example implementation from the pull request that makes use of the DatabaseFailedJobProvider:

public function count($connection = null, $queue = null)
{
return $this->getTable()
->when($connection, fn ($builder) => $builder->whereConnection($connection))
->when($queue, fn ($builder) => $builder->whereQueue($queue))
->count();
}

When dealing with unsuccessful jobs, this feature dramatically improves the scalability and speed of your Laravel applications.

Laravel 10.21 maintains the Laravel framework’s growth, providing developers with a robust and user-friendly environment for developing online applications. Upgrade your Laravel project today to take advantage of these incredible new features!

--

--

LaravelCodeCraft

"Exploring the Laravel universe one line of code at a time 🚀 #LaravelCodeCraft"