Read More
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.
Laravel 10 was released on 14th February 2023. Some new features include better security, performance, and functionality of web applications.
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.
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 |
Prerequisite: To install Laravel 10, you need to have the following prerequisites installed on your system.
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
Build Feature-Rich Web Applications with Our Top-Notch Laravel Development Services
Let’s Begin
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.
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.
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 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 how 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.
Check out the pull request here on GitHub: [10.x] Default to invokable rules
Scale up Your Digital Goals with Our Cutting-Edge PHP Development Solutions
Get Started
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 readonly 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.
See the request on GitHub: [10.x] Drop PHP 8.0
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()
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).
Consider the request on GitHub: [10.x] Uses PHP Native Type Declarations
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.
You can check what’s new in Predis v2 in the changelog.
Check on GitHub: [10.x] Drop Predis v1 support
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 the 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');
Boost Your Business ROI and Generate 2X Growth with Innovative Web Applications
Give a Shot
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.
Here are a few deprecations found in the comparison of the Laravel framework’s master branch and 9.x branch:
handleDeprecation
method in Pull Request #42590assertTimesSent
method Pull Request #42592ScheduleListCommand
’s $defaultName
property 419471eRoute::home
method Pull Request #42614dispatchNow
functionality Pull Request #42591If 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.
Ready to brush up on something new? We've got more to read right this way.