Devs.site

String and Array helpers deprecated in Laravel 5.8

If you use the global string and array helpers in your Laravel project, find out how to update your code for the new version

String and Array helpers deprecated in Laravel 5.8

On the road towards Laravel 5.9 where they will be completely removed, the global Arr and Str helper methods will become deprecated in Laravel 5.8.


If you plan to keep upgrading your Laravel based product to the latest version, you can already start getting rid of the global helper functions that work with arrays and strings. You should use \Illuminate\Support\Str and Illuminate\Support\Arr instead.

Code like

array_add($array, $key, $value);
str_contains($haystack, $needles);

becomes

Arr::add($array, $key, $value);
Str::contains($haystack, $needles);

Basically, everything under Array & Objects and Strings listed here should be changed to the methods listed here and here

0 comments

Specify your e-mail if you want to receive notifications about new comments and replies