“Call to undefined function str_slug()” in Laravel 6.0

旧巷老猫 提交于 2019-12-23 06:49:15

问题


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()


回答1:


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

String and Array

Helpers are removed from Core Framework

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

https://github.com/laravel/framework/blob/5.8/src/Illuminate/Support/helpers.php#L1071

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




回答2:


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', '-');



回答3:


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)



来源:https://stackoverflow.com/questions/57864711/call-to-undefined-function-str-slug-in-laravel-6-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!