72
votes

I've upgraded my laravel 5.8 project to 6.0. It has upgraded successfully but when I'm trying to run the project or installing another package to my project it is giving me error named as "Call to undefined function str_slug()" in session.php. I don't know why....

Call to undefined function str_slug()

3
str_slug() is not available in 6.0. They have changed it to Str::slug. Looks like some of your Laravel code is still from 5.8Cerlin
problem solved... Thanks :)Soft Technoes
I have the same issue, but the str_slug is from the cache.php and session.php files supplied by laravel. How do I get more recent versions of these files?mankowitz
when you update your project into 6.0 these files will be automatic updated at their location if not available then will be created. Run composer update from your terminalSoft Technoes
I had the same problem as mankowitz, but composer update didn't update them. I went on the github of laravel to get the latest code and updated confg/cache.php and config/session.php manually.Jack Wire

3 Answers

133
votes

If you have gone through the upgrade guide then you must know that

String and Array Helpers have been removed from Core Framework

So if if You need to still use the helper install the package

composer require laravel/helpers

and all the helpers are moved to this package

31
votes

String and Array helpers are removed from laravel 6.0 Core Framework

https://laravel.com/docs/6.0/upgrade#helpers

So if You need to still use the helper install the package

composer require laravel/helpers

Or you can use by Laravel facade

use Illuminate\Support\Str;
$slug = Str::slug('Laravel 5 Framework', '-');
2
votes

Personal I hard to do the following on Laravel 6 on the app Controllers add this use Illuminate\Support\Str; then something like this 'slug' => Str::slug($request->title)