At Agira, Technology Simplified, Innovation Delivered, and Empowering Business is what we are passionate about. We always strive to build solutions that boost your productivity.

,

Laravel 5.8 New Features & Updates – Check What's New

  • By Nithin Kumar C N
  • April 5, 2019
  • 781 Views

With the continuous updates & features, Laravel is getting more powerful every day. Again the new update is back, the Laravel 5.8 hitting us with new features & major updates which also automates the process of upgrading from 5.7 to 5.8. Have you started using Laravel 5.8? No or still looking forward to check what’s new in Laravel 5.8? Then this blog got you covered with everything you must know in latest release of Laravel.

Dotenv 3.0

Laravel 5.8 supports brand new dotenv 3.0. It helps us to manage our laravel application’s .env environment file.
What makes so special about dotenv 3.0 is that they are providing support for multiline strings and white spaces at the end of the strings in .env file.
Let’s consider the following example.

DEVELOPMENT_APP_KEY=”specialstringforthis
application”

This will return only ‘specialstringfor’ in Laravel 5.7 versions, but in Laravel 5.8 the entire string ‘specialstringforthis application’ will be parsed.

Email Validation

Although the email validation rules of Laravel got a significant update in Laravel 5.8. Now it will allow international charters to check for email addresses. For example, consider we have the following email validation code.

$request->validate([
'email' => 'email',
]);

If we enter the email as ‘abc@xyz.se’, it will fail in Laravel 5.7. But the new updates helps us to pass it successfully in Laravel 5.8.

Carbon Update In laravel 5.8

Carbon is a date manipulation library and its latest version 2.0 is supported in Laravel 5.8.

Pheanstalk 4.0 Support

Laravel supports the latest 4.0 version of Pheanstalk queue library. If you are using old version of Pheanstalk library in your application, you can upgrade it to the latest version with the help of composer.

Laravel 5.8 Deprecates String And Array helpers

There are no string and array helper functions are available in Laravel 5.8. Here, those helper functions are replaced by Arr:: and Str:: facades.
So you have to replace the existing array_ function such as:

function array_add($array, $key, $value)
Arr::add($array, $key, $value)

New Error Page Introduced In laravel 5.8

Laravel 5.8 comes with new error page which we can use as a template for default 404 page that will suit for range of websites.

Cache TTL

If you are using Laravel’s caching function and also if you are passing an integer to the cache function, it will apply the time to get live in seconds and not in minutes like before. Use the following command to check it.

Cache::put('foo', 'bar', 20);

It will store the item for 20 minutes in Laravel 5.7, but it will happen in 20 seconds in Laravel 5.8.

Best To Read: Laravel API – How to Build REST API with Laravel 5.5 / Laravel 5.6

 

firstWhere method

Laravel 5.8 comes with a new function called firstWhere() which is in integration with collection object. The use of this function is that it will return the single object. For example, consider below code.

$collection = collect([
['name' => Rahul, 'age' => 25],
['name' => 'Prithvi', 'age' => 24],
['name' => 'Parthiv', 'age' => 23],
]);
$collection->firstWhere('name', 'Prithvi');
// ['name' => 'Prithvi', 'age' => 24]

That’s all guys, i have mostly covered the major updates here so start using it & let me know favorite features in comments below. Would like to discuss more about this update with you all.
[contact-form-7 404 "Not Found"]

Nithin Kumar C N

Passionate Senior Software Developer, Expert in PHP, Laravel, JQuery, Angular, With 6 years of experience in web development, he strongly committed himself in delivering authentic applications. Also, he continuously update himself with new technologies & features which drives him to come up with blogs on unique topic.