It’s been around 4.5 years Laravel 5.0 was introduced, and till the time Laravel ecosystem has blossomed and users, as well as developers, have nothing to complain about this free open-source PHP framework. Laravel Passport, Laravel Horizon, Laravel Echo, Laravel Scout are some of the tools that have been introduced since then. Last week on the 3rd Sept 2019, Taylor Otwell decided to introduce 6.0 skipping Laravel 5.9.
I am writing this blog to get you up on the latest features with practical examples to get started with “what’s new in Laravel 6”. However, it’s LTS release that will keep getting updates and patches for a pre-defined duration with bugfixes until 3rd Sept 2021 and the security fixes until 3rd Sept 2022.
Lazy collections
Laravel 6.0 introduces lazy collections that allow you to deal with low memory usage along with substantial data. Lazy Collection has been introduced to deal with large datasets along with keeping the memory usage low.
// This loads all eloquent models into memory at the same time // This may be a huge number if you have thousands of posts $posts = App\Post::all()->filter(function ($post) { return $post->id > 500; });
Source:wwww.auth0.com
String & Array Helpers Moved To Package
The latest updates have eliminated all str_helpers functions by default. A new composer package has been introduced for array and string helpers’ function. To use array and helpers in Laravel 6 is making use of the following composer package.
composer requires laravel/helpers
Carbon 2.0 Supported
Laravel 6.0, has eliminated Carbon 1.x version and added Carbon 2.0. You can read Carbon 2.0 documentation to understand what they have added new. For more read here.
Declaration Of Primary Key Type
Laravel 6.0 has updated performance optimization that is making use of the primary key model.
/** * The "type" * * @var string */ protected $keyType = 'string';
Ignition – The default error page
Ignition – it is a default page error that is introduced in Laravel 6.0 that makes stack traces and debugging expectations better. It displays details about the user, context, request, application, and debug. The debug tab shows logs, queries, and dumps. The Ignition error page can also be installed with Laravel 5 application.
Improved Authorization Responses
A static method inspect is added to the class Gate to check whether the user is authorized to access the resource. It can be used as shown below. A new static method inspect is added to the Gate to ensure the user is authorized to access the resource or not.
public function view(User $user, Flight $flight) { return $this->deny('Detailed here.'); }
You can easily retrieve response as well as message using the method Gate::inspect.
For more read here.
Job Middleware
Taylor has specifically introduced this feature to perform the job through specified middleware to wrap the custom logic around the execution of queued jobs and separate the logic from jobs.
public function handle() { Redis::throttle('key')->block(0)->allow(1)->every(5)->then(function () { info('Lock obtained...'); // Handle job... }, function () { // Could not obtain lock... return $this->release(5); }); }
Source:www.fastcomet.com
Laravel UI
The frontend scaffolding that was offered in the previous Laravel 5.x releases is now removed to a separate Composer package like, Laravel/UI.
composer require laravel/ui php artisan ui vue --auth
Laravel Vapor Compatibility
Laravel Vapor is now compatible with Laravel 6.0. It’s auto-scaling serverless deployment platform.
Localization
It’s a handy feature to translate Spark-based apps in their preferred local language, and it also supports the right to left text layouts.
Support Policy
Laravel 6.0 bug fixes are provided for two years, and security fixes is provided for 3 years. For all further libraries, including Lumen, only the latest release receives bug fixes.
Version | Release | Bug Fixes Until | Security Fixes Until |
---|---|---|---|
5.5(LTS) | August 30th, 2017 | August 30th, 2019 | August 30th, 2020 |
5.6 | February 7th, 2018 | August 7th, 2018 | February 7th, 2019 |
5.7 | September 4th, 2018 | March 4th, 2019 | September 4th, 2019 |
5.8 | February 26th, 2019 | August 26th, 2019 | February 26th, 2020 |
6.0(LTS) | September 3rd, 2019 | September 3rd, 2021 | September 3rd, 2022 |
Wrapping Up
In today’s constantly changing world, very few frameworks and platforms have stability. But, PHP’s most used framework – Laravel is here to stay.
This framework has the whole ecosystem that includes top-notch products such as Forge, Cashier, Valet, Nova, Tinker, and it is still exploring and implementing other products. The last arrived and joined in the family is Laravel Vapor – serverless deployment framework. Otwell and the team of Laravel are only introducing great things.
The latest release has created a wow factor amongst the community due to its incredible set of features. Laravel holds broad community support, and it looks like the future of the new framework is bright. At Bacancy Technology, we have highly skilled Laravel developers whom you can hire upon your convenience and requirement to optimize the performance of your existing Laravel application. You can also hire Laravel developer from us to build solutions of varying size with supreme perfection.
To know more upgrades in-detail, check out here.