Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Laravel 6 — What's New?

DZone 's Guide to

Laravel 6 — What's New?

See what's new in this beloved PHP framework.

· Web Dev Zone ·
Free Resource

steel-architecture-modern-building


This month we have witnessed a major release of our favorite PHP framework. Laravel is turning eight this year, and the older it gets, the more we like it. Just like a kid… Not to say we didn’t like it before! 

In this article, I’ll give you a quick run through on the most important changes with this major release. 

However, first I wanted to look into Laravel's popularity. I was unable to find any definite statistics in regards to the usage of each of the popular PHP frameworks, so I had to do my own research. 

I turned to Google Trends and compared all of the greats. This is by no means is a conclusive usage indicator — it does however give us an idea of the interest in the frameworks and clearly indicates Laravel’s dominance.

Comparing Laravel search volume against other PHP frameworks


You may also like: Reasons Why Laravel Is the Best PHP Framework in 2018.

New Features

Vapor

Vapor is feature I am the most excited about as a software developer. It is an "auto-calling, serverless deployment platform for Laravel, powered by AWS Lambda."

Meaning that you don’t have to worry about servers and all the hassle that comes with them:

  • Automatically scale infrastructure based on the traffic to you web app. Usage spikes are no longer an issue.
  • Don’t worry about keeping the server up to date.
  • No messing with load balancers, security groups, DNS groups etc.

I am delighted that I will be able to focus on the development, rather than spending time on the unexciting infrastructure. I think this will ultimately benefit the users as developers will now have more time to think about features.

It is a pricey product, which will set you back $39 per month, but it will definitely save you a lot of time. Here’s the complete list of features. 

Ignition

Ignition is only a small package compared to Vapor. It provides a customisable error screen and instant runnable solutions to common errors. "Looks like you forgot to run your migrations. Want me to do it for you? Yes, please!"

Ignition interface

Lazy Collections

Laravel’s Collection class comes with an amazing list of useful methods. Lazy Collections are the latest addition to this list, and they help you look after your server’s memory better. 

Let’s say you had to iterate over thousands of Eloquent models which could be done in the following way

$users = App\User::all()->filter(function ($user) {
    return $user->id > 500;
});


All those models would have to be loaded into memory first, which is not a good thing. Now, you can use  a cursor, which returns a LazyCollection. This allows you you to run a single query against the database and at the same time load only one Eloquent model into memory at a time. 

$users = App\User::cursor()->filter(function ($user) {
    return $user->id > 500;
});

foreach ($users as $user) {
    echo $user->id;
}


Job Middleware

You can now write reusable middleware for jobs. Small time savings for a developer who uses jobs extensively.

Improved Authorization Responses

If you work with Gate(s) you will be able to expose custom authorization messages to end users.

Support

This version will be supported until September 3rd, 2022 so there’s plenty of time to enjoy this build. 

Conclusion

While most of the changes to the plaftform are not too extreme, which is a positive, we can see the direction this framework is taking. Vapor is a great move by Taylor and the Laravel team and will yet again make developer lives easier. 

If you’re not using this version yet I do hope you are now considering an upgrade. 

Laravel 5.8 will be supported for another year. If you’re using 5.7 or older, keep in mind that the support has expired this month and no further security fixes will be released. Therefore, if you have any regard for your user security please ensure you do upgrade to the latest and the greatest as soon as possible. 


Further Reading

Topics:
laravel 6 ,laravel 5 ,laravel ,new features ,upgrade ,php ,codeigniter ,symfony ,web dev

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}