laravel 5.8 install
Via Laravel Installer
composer global require laravel/installer
laravel 5.8 requirements
- PHP >= 7.1.3
- OpenSSL PHP
- PDO PHP
- XML PHP
- Ctype PHP
- JSON PHP
- BCMath PHP
- Mbstring PHP
- Tokenizer PHP
Deprecated String and Array Helpers Functions
In my point of view to Latest new features in laravel 5.8, removing all the PHP string and array global methods in PHP Latest frameworks Like laravel 5.8 laravel 5.8 github. we can not use any more methods like as a PHP array_add, or array_first, php functions Like array_last, str_slug, str_random or more…., instead of this methods we can use same Laravel latest included method using Illuminate\Support\Arr as well as Illuminate\Support\Str facade like as bellow example.
using Illuminate\Support\Arr or Illuminate\Support\Str facade
use Illuminate\Support\Arr; $myArray = Arr::add(['name' => 'Admin'], 'total', 852); // ['name' => 'Admin', 'total' => 852]
Example 2: Laravel 5.8 String Function
use Illuminate\Support\Str; $random = Str::random(10);
Laravel 5.8 Added Blade Template File Path in Compiled file
As we know laravel 5.8 upgrade compile blade file, but as we 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:
resources/views/welcome.blade.php
Laravel
Cache TTL in Seconds Change
Laravel 5.8 update cache time in ttl in minutes into seconds. so basically, We need to add time in seconds in put(), putMany(), add() as well as remember().
We can display bellow example to how to set time like as bellow example:
Cache::put('jk', 'jadavkaorat', now()->addSeconds(60));
Update Email Validation Rule
In this latest Laravel feature, laravel 5.8 updated email validation rule. laravel had already email validation, so in this server side input validation they latest Laravel update feature.
The users email validation check rule now data checks if the main email is like data RFC5630 compliant rules.
before if We include ‘admin@domain_name.com’ then it some data consider invalid but and then it consider valid.
Laravel 5.8 Added firstWhere in Collection
Laravel 5.8 added new simple function firstWhere() with data collection object. We can get single object using firstWhere method instead of first().
Simple Example for Laravel 5.8 firstWhere in MySQL
$collection = collect([ ['name' => 'Hitesh', 'age' => 29], ['name' => 'Mayur', 'age' => 26], ['name' => 'Virat', 'age' => 23], ]); $collection->firstWhere('name', 'Mayur'); // ['name' => 'Mayur', 'age' => 26]
Unquoted MySQL JSON Values in Database
this laravel 5.8 feature for json datatype column main supported only. the any query MySQL builder will now return unquoted JSON Data values when using MySQL as well as MariaDB.display bellow example:
Example Laravel 5.8 Unquoted MySQL JSON Values
$data_value = DB::table('items')->value('details->language'); dump($data_value); // Laravel 5.8... 'fr'