Laravel 5.8 New Features List
In this post we will give you information about Laravel 5.8 New Features List. Hear we will give you detail about Laravel 5.8 New Features ListAnd how to use it also give you demo for it if it is necessary.
PHP laravel introduce new version laravel 5.8 with new features. Today laravel 5.8 is released and available for all. laravel 5.8 added new feature like cache TTL changes and lock, Deprecate string and array helper methods, update email validation, Automatic Policy Resolution, PHP dotenv, added firstWhere function in collection, database mysql json value etc.
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.
*) 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 IlluminateSupportArr and IlluminateSupportStr facade like as bellow example.
use IlluminateSupportArr;
$array = Arr::add(['name' => 'Hardik'], 'price', 200);
// ['name' => 'Hardik', 'price' => 200]
use IlluminateSupportStr;
$random = Str::random(10);
*) Added 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.
*) Added 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…
Hope this code and post will helped you for implement Laravel 5.8 New Features List. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs