Laravel 6.0

Laravel 6.0: New Features and Upgrades

On 3rd September 2019, a new version 6.0 of Laravel was released, taking forward the tradition of releasing a new version almost every 6 months. The new version indicates how the framework is growing with little but important development in features and the modification to semantic versioning. Through this blog, you will get to know the new updates that are important to know to decide whether you should update to the new version.

Now, know here what’s new –

Semantic versioning –

The new version of Laravel has made changes in the semantic versioning. This means that the new software version must be used in the v.v.v form. This means respectively minor, major, patch.

Lazy collections –

Lazy collections use PHP generators to considerably lessen the usage of memory during working with big data sets. The large number can be of external files or eloquent models that are using Laravel’s collection logic for processing. Through the lazy collection feature, only the part of the model or file will store in the memory at a time for the processing.

use Illuminate\Support\LazyCollection;

$logs = LazyCollection::make(function () {
   $handle = fopen('./log.txt', 'r');
    while (($line = fgets($handle)) !== false) {
          yield $line;
     }
});

foreach ($logs as $line) {
    echo $line . '<br>';
}

 

Job middleware –

The new version of Laravel now supports definite middleware for jobs. In place of manually adding additional boilerplate code around your job, now you can take out it into middleware. Th just put it together to the job.

public function middleware() {
     return [new SomeMiddleware];
 }

 class SomeMiddleware {

      public function handle($command, $next) {
           return $next($command);
      }

 }

Improvements to Eloquent Subqueries –

Eloquent has at all times made it trouble-free to run difficult queries. The new version gives you even more. It will help you in running Subqueries, or when you have query within a query, in one call. This is helpful when you have to choose information from 2 tables with an association.

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

Improved authorization responses –

The Laravel’s version 6.0 has introduced a new method in place of Laravel’s innovative authentication with gates for authorization. It makes easy to give custom messages to users all through authorization requests. For e.g. an error message when users requests are refused.

Gate::define('update-post', function ($user, $post) {
  return $user->id == $post->user_id;
});

Laravel vapor –

The new version upholds Laravel vapor, powered by AWS, an auto-scaling server-less deployment stage for Laravel.

Laravel UI is now a composer package –

If you are exploiting some of Laravel’s bootstrap /VUE code and built-in front end scaffolding then with the release of the new version you will have to use the first-party Laravel UI composer package. This means that now make: auth command will not any more generate defaults auth views for registration, login or any other thing.

$ composer require laravel/ui
$ php artisan ui vue --auth
$ npm install
$ npm run dev

New website –

While it is not a particularly a Laravel upgrade, but it has been provided with a new layout and a logo. And also the Laravel documents pages have a new appearance.

New exception details via Ignition –

Now, ignition is the fresh default fault page for the Laravel version 6.0 and it will make chasing bugs easier with some specific features of Laravel like recommended solutions for the general difficulty.

An example of Laravel ignition:

laravel-ignition

Kadam Technologies is a Jaipur based Web Development Company, having a team of Experienced Developers who always update themselves with the latest technologies as per the trends in the market.

KadamTech developers developing the new web applications using Laravel 6.0 and also started updating old applications to Laravel’s latest version.

If you are looking for developers to develop your website in Laravel 6.0 then you can contact us through our website.

1 thought on “Laravel 6.0: New Features and Upgrades”

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × three =