What is new to Laravel 6?

What is new to Laravel 6?


Today Laravel 6 has finally officially released. Let's have a detailed look at what is changing in Laravel 6.

Laravel 6 changelog

Laravel 6.0 (LTS) continues the improvements made in Laravel 5.8 by introducing semantic versioning, compatibility with Laravel Vapor, improved authorization responses, job middleware, lazy collections, sub-query improvements, the extraction of the frontend scaffolding to the laravel/ui Composer package, and a variety of other bug fixes and usability improvements.

Semantic Versioning

Laravel now follows the semantic versioning standard. This makes the Laravel consistent with the other first-party packages which already followed this versioning standard. The Laravel release cycle will remain unchanged.

Serverless Laravel with Vapor

Laravel 6.0 provides compatibility with Laravel Vapor, an auto-scaling serverless deployment platform for Laravel. Vapor abstracts the complexity of managing Laravel applications on AWS Lambda, as well as interfacing those applications with SQS queues, databases, Redis clusters, networks, CloudFront CDN, and more.

Improved Exceptions Via Ignition

Laravel 6.0 ships with Ignition, a new open source exception detail page created by Freek Van der Herten and Marcel Pociot. Ignition offers many benefits over previous releases, such as improved Blade error file and line number handling, runnable solutions for common problems, code editing, exception sharing, and an improved UX.

Improved Authorization Responses

In previous releases of Laravel, it was difficult to retrieve and expose custom authorization messages to end users. This made it difficult to explain to end-users exactly why a particular request was denied. In Laravel 6.0, this is now much easier using authorization response messages and the new Gate::inspect method. For example, given the following policy method:

 * Determine if the user can view the given flight.
 * @param  \App\User  $user
 * @param  \App\Flight  $flight
 * @return mixed
public function view(User $user, Flight $flight)
    return $this->deny('Explanation of denial.');

// & then we can get the message with the response object

$response = Gate::inspect('view', $flight);

if ($response->allowed()) {
    // User is authorized to view the flight...

if ($response->denied()) {
    echo $response->message();

Job Middleware

Job middleware allow you wrap custom logic around the execution of queued jobs, reducing boilerplate in the jobs themselves. For example, in previous releases of Laravel, you may have wrapped the logic of a job's handle method within a rate-limited callback.

Lazy Collections

Laravel 6.0 introduces a LazyCollection, which leverages PHP's generators to allow you to work with very large datasets while keeping memory usage low.

For example, imagine your application needs to process a multi-gigabyte log file while taking advantage of Laravel's collection methods to parse the logs. Instead of reading the entire file into memory at once, lazy collections may be used to keep only a small part of the file in memory at a given time:

use App\LogEntry;
use Illuminate\Support\LazyCollection;

LazyCollection::make(function () {
    $handle = fopen('log.txt', 'r');

    while (($line = fgets($handle)) !== false) {
        yield $line;
->map(function ($lines) {
    return LogEntry::fromLines($lines);
->each(function (LogEntry $logEntry) {
    // Process the log entry...

Or, imagine you need to iterate through 10,000 Eloquent models. When using traditional Laravel collections, all 10,000 Eloquent models must be loaded into memory at the same time:

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

However, beginning in Laravel 6.0, the query builder's cursor method has been updated to return a LazyCollection instance. This allows you to still only run a single query against the database but also only keep one Eloquent model loaded in memory at a time. In this example, the filter callback is not executed until we actually iterate over each user individually, allowing for a drastic reduction in memory usage:

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

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

Eloquent Subquery Enhancements

Laravel 6.0 introduces several new enhancements and improvements to database subquery support. For example, let's imagine that we have a table of flight destinations and a table of flights to destinations. The flights table contains an arrived_at column which indicates when the flight arrived at the destination.

return Destination::addSelect(['last_flight' => Flight::select('name')
    ->whereColumn('destination_id', 'destinations.id')
    ->orderBy('arrived_at', 'desc')

Laravel UI

The frontend scaffolding typically provided with previous releases of Laravel has been extracted into a laravel/ui Composer package. This allows the first-party UI scaffolding to be developed and versioned separately from the primary framework. As a result of this change, no Bootstrap or Vue code is present in default framework scaffolding, and the make:auth command has been extracted from the framework as well.

In order to restore the traditional Vue / Bootstrap scaffolding present in previous releases of Laravel, you may install the laravel/ui package and use the ui Artisan command to install the frontend scaffolding:

composer require laravel/ui

php artisan ui vue --auth

Laravel Framework Rebranding

Along with all of the above changes, Laravel has new Logo & new website.

How to upgrade to Laravel 6?

Official document say's much about how we can upgrade to latest version of laravel.

Your project may have other dependencies and external packages that can increase that time, so keep that in mind when you decide to upgrade.

In your composer.json file, change the Laravel framework dependency from 5.8.* to ^6.0. If you're on a version earlier than 5.8, it's recommended to upgrade up to 5.8 before making the switch to 6.0.

// In composer.json 
"laravel/framework": "^6.0",^

& update your dependencies. Make sure to check for other dependencies which are supported with laravel 6 or not before.

With bug fixes for the previous LTS release ending very soon, it may be worth it to upgrade to 6.0 so that you know your project will be supported for a couple more years.