What's New in Laravel 10? Latest Features, Updates, and Deprecations to Note!


By : Biztech

What’s New in Laravel 10? Latest Features, Updates, and Deprecations to Note!1


Laravel was first released in June 2011 and is currently one of the most used PHP frameworks with over 44k active users. With its MVC architecture and robust backend capabilities like routing, caching, and validation, it is a doting backend framework.

Over the years of its existence, it has simplified PHP development substantially. Whether it is beginner-level development or enterprise-level development, Laravel has always been adept at making it more convenient for developers.

And now that Laravel 10 update is here, you must be wondering if there are any mindblowing cards left to be played. Well, this blog post deals with the concern of businesses and Laravel developers who are keen to know about the newly released Laravel 10 update.

So without further ado, let’s begin!

Introduction to Laravel 10

Before Laravel 9 was released, every major update used to release every 6 months. But recently, the company has changed its Laravel release schedule and now it introduces major updates once a year. So, after a year of Laravel 9’s release (on 8th February 2022), Laravel 10 was up for release on February 7, 2023.

However, the update was actually rolled out on 14 February 2023. The bug fixes for Laravel 10 will be available till August 6, 2024. As for security fixes, they will remain accessible until February 4, 2025.

Here, look at a few key points of this update:

  • The support for PHP V8 has ended with Laravel 10
  • Laravel 10 has removed all the deprecated methods of Laravel 9
  • In Laravel 10, the app skeleton code now will use native type declaration
  • Eager loading optimization
  • Removal of DispatchNow()

That’s just the trailer of things to expect of this update, you will read in detail about the features and deprecations going forward.

New Laravel 10 Updates and Features

Whether you are a developer or a business owner, everyone’s interested to learn about the new additions made in Laravel 10. So, let’s first look into what’s new!

Minimum supported PHP v8.1

As you would already know that Laravel is a PHP-based framework. But, what you don’t know is that the minimum requirement for the PHP version is 8.1 with Laravel 10. So, upgrading to the Laravel latest version 2022 would mean upgrading to PHP v8.1.

Henceforth, you get to use PHP features like fsync(), fdatasync(), readonly properties, enumerations, and PureSection type, etc. with Laravel 10.

PHP 8.2 is supported

PHP 8.2 is its latest version and was released in December 2022. Despite being present for such a short time, it is still supported with Laravel 10. So, if you’re excited to work with the latest PHP version, you can totally do it with Laravel 10.

You get to use interesting new features like DNF types, new ReadOnly classes, fetching enum properties in const expressions, etc. Besides, the PHP 8.1 version is expected to meet the end of support before 2025.

Additionally, PHP 8.2 works well with Laravel Forge, Vapor, Envoyer, and other technologies in the Laravel ecosystem. So, if you plan wisely during development, you can get the most by using a stable PHP 8.2 version.

Native type declaration

Prior to this update, Laravel skeleton code used DocBlocks to explain the code and what kind of responses and parameters to expect. But in Laravel 10, native-type declarations are used instead of DocBlocks.

Thus, all codes generated by the framework have return types and type hints. These type-hints are carefully added to the platform and also support backward compatibility. Here are some of the declaration types added in Laravel 10:

  • Method arguments
  • Return types
  • In closure arguments, userland types are allowed
  • Removal of redundant annotations
  • Typed properties are not included

So, instead of writing the below-mentioned piece of code:

public function create({{ user }} $user)
You can write:
public function create({{ user }} $user): bool

This change is to help IDEs determine the type of parameter and response so they can function better and perform features like auto-completion with ease.

Default invokable validation rules

Up until Laravel 9, if you wanted to create an invokable validation rule, you had to add an ‘invokable’ flag for this purpose. For instance, look at this piece of code:

#Create a rule class
#illuminate\Contracts\Validation\Rule interface
artisan make: rule uppercase
#Flag to create an implicit and invokable rule
artisan make: rule Uppercase -- invokable
artisan make: rule Uppercase - invokable -implicit

But, Laravel 10 has introduced a new feature wherein all Laravel validation rules are invokable by default and developers don’t have to add flag. Instead, you can just write this to create an invokable validation rule:

artisan make : rule customrule

Upgraded Laravel packages

Alongside Laravel model, its official packages have also been updated for maximum efficiency. Some of the recently updated packages include Horizon, Passport, Valet, Breeze, Dusk, Pint, Scout, Cashier Stripe, etc.

Supports native column modification

Before this new update in Laravel, if you wanted to modify columns using the change() function, you had to depend on an additional package named DBAL (doctrine/dbal). However, this dependency has been completely removed in Laravel 10.

You do not need to use the DBAL package while modifying a column in SQL Server, MySQL, and PostgreSQL.

Eager loading optimization

The eager loading feature was introduced in Laravel to overcome the ‘N+1’ problem caused because of lazy loading where a user had to run N+1 queries to retrieve an answer. However, the eager loading also required the execution of a significant number of impossible queries.

So, even if there aren’t any keys that are to be loaded, Laravel still executed these queries without the proper information. This issue has been resolved in Laravel 10 as it will now check for any available keys and then only run the database queries. In case there aren’t any keys, it will provide an empty collection, and queries won’t be needed.

Laravel Pennant

For web applications that are continuously getting evolved and modified with new features, the use of feature flags is like a boon. With the use of a feature flag, you will be able to disable and amenable features as you need. For this, you do not need to do any modification in the source code or redeploy the application.

Pretty interesting, right?

Laravel 10 has brought a package Pennant for you so you can easily manage your feature flags. It has a database and an in-memory array driver. Thus, defining a new feature, and checking if it is enabled or disabled is now easier than ever.

Default pest scaffolding

Scaffolding refers to creating the structure of a website or application. W ith Laravel 10, whenever you create a new project, you can see that pest test scaffolding is by default enabled. Thus, while using the Laravel installer, you just have to make use of the –pest flag like this:

laravel new example-abc-app --pest

String password helper

A new security feature is added with Laravel 10 wherein you can create a random and highly secured password of a chosen length. To do so, you can write:

$password = Str::password(12);

Security enhancement for Timebox class

Your Laravel-built web application is now more secure from timeless timing attacks as the Timebox class has been optimized. The class is now capable of handling exceptions thrown at the time of callback execution.

Supports PHPUnit 10

PHPUnit 10 was released recently on 3rd February 2023 and is a framework for PHP unit testing. Despite being the latest release, Laravel 10 still supports this version alongside its predecessor updates PHPUnit 8 and 9.

Database expressions

This feature was a last-minute addition to Laravel 10 as it was added just 4 days prior to its release. Earlier, working with multiple databases was quite a hassle.

For instance, you are using two databases such as MySQL and PostgreSQL. Now, if you needed to return the first non-null value of a list or table as an alias, you would need to write raw database code. And you will have to do this, again and again, each time you perform such a request.

But with the help of new and reusable database expressions, you can implement these statements and expressions only once. While the coding for database expressions might look lengthy to you, it is still a better choice than writing raw database code every time.

While these are some of the most interesting additions you will see in Laravel 10, it has also dropped support for certain tools, packages, and features.

Let’s check those!

Read More: Django vs Laravel

Removal and Deprecations in Laravel 10

Removal and Deprecations in Laravel 10

  • Dropped support for PHP 8
  • Predis version 1 isn’t supported anymore
  • After the introduction of dispatchSync(), the method dispatchNow was deprecated in Laravel v9. And now, it has been removed from Laravel 10.
  • All deprecations from Laravel 9 have been removed like Route::Home method, assertTimesSennt method, handleDeprecation method, deprecated dates property, etc.
  • Removal of getBaseQuery method.
  • MocksApplicationServices property has been removed.

How to Install Laravel 10 and Get Started?

The core team of Laravel has ensured that it is accessible by developers on a platform of their choice. Thus, installing it and getting started is simple. Here, I have enlisted how to install it on Windows and Mac.

On MacOS

You can utilize Laravel sail or Docker to quickly get started. Next, browse to the file directory where you want to install the software and write the terminal command mentioned below:

curl -s "https://laravel.build/example-abc-app" | bash

It is to note that the application name only accepts dashes, underscores, and alphanumeric characters. Follow through the installation steps mentioned on your screen to complete the process. If you are using sail for installation and development, you need to write the following piece of code in terminal

./vendor/bin/sail up

With the help of Sail’s in-built solution, you should be able to access your app on http://localhost

On Windows

Whether you use Windows 10 or 11, you need to prepare your system for one of the two following things to get started:

  1. Create and operate a virtual machine on your system, or
  2. Create a Windows subsystem that allows you to run Linux command line tools and file systems.

After you fulfill these requirements, you can use the same procedure as for MacOS by writing the aforementioned commands in the terminal and get started.

Final Thoughts

Ever since the Laravel news of the latest version circulated, it had piqued the interest of developers and business owners. But, the extent of additions and improvements was still unknown. Now that Laravel 10 has officially been released, we can see that the core team has not only introduced many new features but also paid attention to many pull requests by community contributors.

The update also extends support for multiple latest technologies, so you are spoilt for options. Rest, it will be up to your development tactics to utilize it in the best way possible. And for that, you may need to hire dedicated Laravel developers who have the right skills and experience in your sector.

If you are still looking for a team that can handle your Laravel project through and through, BiztechCS can be of great help. We have over 16 years of experience in IT with expertise in many industries to help you with the development and deployment.

Get a Free Consultation

    ✓ 100% Guaranteed Security of Your Information