What’s New in Laravel 10? Latest Features and Updates
After having a stronghold in the market with the popular Laravel framework, have you ever wondered, “Is there anything that Laravel offers to PHP developers?”
We should admit the fact that Laravel has already simplified PHP development for developers. Well, there’s a myth out there; it has spoiled developers into believing that the learning curve of PHP has become easy. Hence, PHP is the easiest programming language.
So, what’s there in the box of Laravel for Laravel developers? Or has it exhausted all possible means to support PHP developers?
And you also must be wondering what made me ask you such questions?
Because it’s a surprise for Laravel developers.
Yes, Laravel 10 is now finally available in the market.
There are some modifications and new features, coming with this new version of the Laravel PHP framework. And this is what we are going to cover in this article: the latest version of Laravel – Laravel 10.
We will talk about how to install Laravel, its new features, fixes, and upcoming versions.
- Introduction to Laravel 10
- Laravel Release Dates
- How to Install Laravel 10?
- Laravel 10 New Features and Updates
- Deprecations in Laravel 9 and Removal from Laravel 10
- How to Test Laravel 10?
- Planning to Shift to Laravel 10?
Introduction to Laravel 10
The latest version of Laravel (Laravel 10), released on 7th February 2023, offers several new features that enhance the performance, security, and functionality of web apps.
Before Laravel 9, each version of Laravel was released every six months. But the makers have decided to release a new version annually after the release of Laravel 9. Just to let you know, Laravel 9 was released on 8th February 2022. And now, exactly after one year, they decided to release Laravel 10.
Previous versions of Laravel have set a standard in the dev community, which is why users and developers have high expectations from the latest version – Laravel 10.
So, if you are an experienced Laravel developer or even a newbie, Laravel 10 has a lot to offer.
Laravel Release Dates
The Laravel team used to release two major versions annually, one in every six months.
However, the creator of Laravel, Taylor Otwell, changed the release cycle with a single major version in a year.
With Laravel 10 released on February 9, 2023, the executed release schedule is as follows:
Laravel 11: February 6, 2024
Moreover, as per the support policy, bug fixes support will be provided for 18 months, and security updates for two years for all Laravel versions.
So, we can calculate the security updates and bug fixes schedules for the following versions:
Laravel Versions | Bug Fixes Date | Security Fixes Date |
---|---|---|
Laravel 9 | Until 8th August, 2023 | Until 6th February, 2024 |
Laravel 10 | Until 6th August, 2024 | Until 4th February, 2025 |
Laravel 11 | Until 4th August, 2025 | Until 2nd February, 2026 |
How to Install Laravel 10?
Prerequisite: To install Laravel 10, you need to have the following prerequisites installed on your system.
- PHP >= 7.3.0
- Composer
It’s very easy to install Laravel 10. However, you have to follow a few steps for Laravel 10 installation in your system.
Laravel installer comes with a --dev
flag, which installs the main branch from the laravel/laravel repository.
Allow us to give you a quick explanation to understand the Composer command:
laravel/laravel
: The package for the Laravel installationexample-radixweb-app
: The new directory for your new project (can be changed)dev-master
: The next version of Laravel (in this case, Laravel 10)
laravel new example-radixweb-app --dev
Or, if you prefer to explicitly use Composer:
composer create-project --prefer-dist laravel/laravel example-radixweb-app dev-master
Bingo! You have successfully installed the latest version of Laravel 10.
Once you are done with installing Laravel 10, you can check that version by navigating to the new directory example-radixweb-app
and run the artisan command:
$ php artisan --version
Laravel Framework 10.x-dev
Laravel 10 New Features and Updates
We always get excited with the new release of any technology or framework as it brings the addition of new features. So, let’s go through some new features and updates in Laravel 10.
Artisan Command Becomes More Interactive
The CLI (Command Line Interface) of Laravel called Artisan has become more interactive with the latest release of Laravel 10. Even if you forget to pass the name after creating a model, you can do it with the new Artisan.
php artisan make:model
Artisan will not show any error if it doesn’t fetch any model name. Instead, it will ask you the name of it and if you want to create a factory, migration, etc.
Invokable Validation Rules by Default
When it comes to PHP, “invokable” object is one type of object that can be called a function. You can achieve this by using __invoke
magic method in the class definition of the object.
Laravel 9 was offering invokable validation rules using --invokable flag
with php artisan make:rule
command.
When an object is used in a situation where a function call is anticipated, such as using ()
operator, the __invoke
method is immediately enabled. When a function is called on an object that has a __invoke
method, PHP will automatically run the code inside of that method.
php artisan make:rule LowerCase
Let's see what invokable validation rules look like:
namespace App\Rules;
use Illuminate\Contracts\Validation\InvokableRule;
class Uppercase implements InvokableRule
{
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param Closure(string): Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
*/
public function __invoke($attribute, $value, $fail)
{
if (strtolower($value) !== $value) {
$fail('The :attribute must be lowercase.');
}
}
}
The boilerplate code is significantly simpler and shorter. People will be less frightened by the idea of creating custom validation rules as a result of Laravel 10.
No Longer Support for PHP 8.0
The latest release of Laravel 10 does not support PHP version 8.0.
Hence, you must have a minimum PHP 8.1 version to install or use Laravel 10. As a result, you can expect to see PHP 8.1 features used in the Laravel framework, like read-only properties.
But calm down. You don’t need to update your Laravel apps to the latest version as soon as the new version is released.
This is very important when you are working on your client’s project and their entire business depends on that project.
You need to move forward slowly with extensive testing.
Uses Native Types Instead of Docblocks
Laravel 10 now uses native types and drops docblocks. Well, this massive PR will be implemented throughout the Laravel organization.
If we give you an example, then schedule()
the method in app/Console/Kernel.php will look something like this in the Laravel skeleton:
/**
* Define the application's command schedule.
- *
- * @param Illuminate\Console\Scheduling\Schedule $schedule
- * @return void
*/
- protected function schedule($schedule)
+ protected function schedule(Schedule $schedule): void
Additionally, the group will include generic type annotations, which will significantly enhance coding's autocompletion (given that your code editor supports generics).
Laravel 10 Dropped Support for Predis v1
If you are using Predis v1 in your project, it’s time to move to the new version 2 now.
Besides, you can use the native Redis extension of PHP. This is the fastest extension, which will enhance the speed of your website when you get maximum traffic. This is my opinion.
Removed dispatchNow()
Laravel 9 deprecated it in favor of dispatchSync()
. So, you have to identify a replacement for each of your projects. Even though the modification may be fatal, it is very simple to rectify.
But, here, we can give you a recommendation to use sync
. Using the sync
queue drive, you can set the queue
property of your job to sync.
Let’s understand the example of how to execute a job immediately in Laravel 10 using the sync
queue drive.
// in your job class
public $queue = 'sync';
// in your controller or other code
dispatch(new YourJob($data))->onQueue('sync');
Deprecations in Laravel 9 and Removal from Laravel 10
The Laravel team has removed features that were deprecated in Laravel 9 by releasing a major release. Additionally, it implies that you should thoroughly test any Laravel applications you may want to upgrade to version 10.
How to Test Laravel 10?
If you want to start testing Laravel 10 now, you can install it in a fresh project by using the --dev
flag:
laravel new <your-project-name> --dev
Planning to Shift to Laravel 10?Laravel recently launched its latest version – Laravel 10 - on February 7, 2023, with the latest features and updates for faster and efficient web app development.In short, Laravel 10 new features and enhancements are poised to completely change the web development industry. Laravel 10 has something for everyone, from its advanced capabilities for optimizing workflows to its cutting-edge security features.Laravel 10 will advance your programming abilities whether you are an experienced Laravel developer or a novice.Laravel 10 is leading the charge with the future of web development. And if you, too, are planning to lead your industry, you may connect with the best Laravel development company – Radixweb. We will help you implement Laravel 10 with our expertise or deliver the entire solution from scratch with the latest version of Laravel 10.What are you waiting for? Connect with us and share your requirements now.
0 Comments
CAN FEEDBACK
Emoji