HDTuto.com

Laravel 5.8 Features and Updates | What Is New



In this tutorial, we will talk about new feature an updates of laravel new version laravel 5.8. i will list of what's new features and upgrade point. We will discuss some of the noticeable changes and some of the new additions to the Laravel 5.8 family.

we will see list of main changes in this tutorial about what's new in laravel 5.8 version.

Let's see one by one important updates on laravel 5.8 version. that will help to use in your next project. laravel 5.8 does not change directory structure, so don't worry about that. let's see bellow list.

You can see the list topic of new changes.

  • Deprecated String and Array Helpers Functions
  • Blade Template File Path in Compiled file
  • Cache TTL in Seconds Change
  • Update Email Validation Rule
  • New Method firstWhere in Collection
  • Unquoted MySQL JSON Values in Database

Deprecated String and Array Helpers Functions

In my point of view, removing all string and array global functions in laravel 5.8. you can not use any more functions like array_add, array_first, array_last, str_slug, str_random etc, instead of this functions you can use same method using Illuminate\Support\Arr and Illuminate\Support\Str facade like as bellow example.

use Illuminate\Support\Arr;

$array = Arr::add(['name' => 'Hardik'], 'price', 200);

// ['name' => 'Hardik', 'price' => 200]

use Illuminate\Support\Str;

$random = Str::random(10);

Blade Template File Path in Compiled file

As we know laravel compile blade file, but as you can see your laravel 5.7 or laravel 5.6 Compiled blade files there are no file path of complied.

In laravel 5.8 they provide path of blade template file path as shown in example:

<?php /* /var/www/me/5.8/blog/resources/views/welcome.blade.php */ ?>

<!doctype html>

<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>">

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel</title>

<!-- Fonts -->

<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">

Cache TTL in Seconds Change

Laravel 5.8 update cache time in ttl in minutes into seconds. so basically, you need to add time in seconds in put(), putMany(), add() and remember().

You can see bellow example to how to set time like as bellow example:

Cache::put('hd', 'hardik', now()->addSeconds(60));

Update Email Validation Rule

In this feature, laravel 5.8 updated email validation rule. laravel had already email validation, but in this validation they update feature.

The email validation rule now checks if the email is RFC5630 compliant rules.

before if you add 'hi@example.in' then it consider invalid but now it consider valid.

New Method firstWhere in Collection

Laravel 5.8 added new function firstWhere() with collection object. you can get single object using firstWhere method instead of first().

Let's see example:

$collection = collect([

['name' => 'Hardik', 'age' => 25],

['name' => 'Vimal', 'age' => 24],

['name' => 'Harshad', 'age' => 23],

]);

$collection->firstWhere('name', 'Vimal');

// ['name' => 'Vimal', 'age' => 24]

Unquoted MySQL JSON Values in Database

this feature for json datatype column supported only. the query builder will now return unquoted JSON values when using MySQL and MariaDB.

see bellow example:

$value = DB::table('products')->value('details->language');

dump($value);

// Laravel 5.8...

'fr'

There are more new small small features added by laravel 5.8 but here is a most changes. i hope it can help you...




February 28, 2019 | Category : PHPLaravelLaravel 5Laravel 5.8
Related Posts



Blog Search