Array & String Helpers deprecated on Laravel 5.8

The global array & string helpers are deprecated with the release of Laravel 5.8 version. We still have the \Illuminate\Support\Str & \Illuminate\Support\Arr classes. We can use them directly.

// Deprecated
$array = ['products' => ['desk' => ['price' => 100]]];
$flattened = array_dot($array);
// Can use this way
use Illuminate\Support\Arr;
$array = ['products' => ['desk' => ['price' => 100]]];
$flattened = Arr::dot($array);
// ['products.desk.price' => 100]

You can check out the documentation for other helpers. You can look at the PR 26898 and commit itself for other info. If you want the helpers back all you need is to install this package and you will have them in your Laravel application.

composer require laravel/helpers

Happy Coding ! 🙂

 

Leave a Reply

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

Pin It on Pinterest