Laravel 6.0 中的“调用未定义函数 str_slug()”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/57864711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Call to undefined function str_slug()" in Laravel 6.0
提问by Soft Technoes
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....
我已将 Laravel 5.8 项目升级到 6.0。它已成功升级,但是当我尝试运行该项目或将另一个包安装到我的项目时,它在 session.php 中出现名为“调用未定义函数 str_slug()”的错误。我不知道为什么......
Call to undefined function str_slug()
Call to undefined function str_slug()
回答by Manojkiran.A
If you have gone through the upgrade guide then you must know that
如果您已经阅读了升级指南,那么您必须知道
Stringand Array
字符串和数组
Helpers are removed from Core Framework
从核心框架中删除助手
https://laravel.com/docs/6.0/upgrade#helpers
https://laravel.com/docs/6.0/upgrade#helpers
https://github.com/laravel/framework/blob/5.8/src/Illuminate/Support/helpers.php#L1071
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
并且所有的助手都被移动到这个包
回答by Masood Khan
String and Array helpers are removed from laravel 6.0 Core Framework
从 Laravel 6.0 核心框架中删除字符串和数组助手
https://laravel.com/docs/6.0/upgrade#helpers
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
或者你可以通过 Laravel 门面使用
use Illuminate\Support\Str;
$slug = Str::slug('Laravel 5 Framework', '-');
回答by user3719458
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)
个人我很难在应用程序控制器上的 Laravel 6 上执行以下操作,use Illuminate\Support\Str;
然后添加类似的内容 'slug' => Str::slug($request->title)