将Laravel从5.6升级到6.0后,对未定义的str_random()函数的调用不起作用 [英] After upgrading Laravel from 5.6 to 6.0, Call to undefined str_random() function not working

查看:94
本文介绍了将Laravel从5.6升级到6.0后,对未定义的str_random()函数的调用不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Laravel从5.6升级到6.0.以前,默认的辅助功能在控制器上运行良好,但现在显示为"未定义".在我的控制器中,我使用了以下内容.

I have upgraded Laravel from 5.6 to 6.0. Previously, default helper functions were running fine on the controllers, but now it says "undefined." In my controller, I have used the following.

$filename = str_random(12);

我遇到以下错误.

消息:调用未定义的函数App \ Http \ Controllers \ str_random()"

message: "Call to undefined function App\Http\Controllers\str_random()"

我还使用了 random()函数,它的意思是相同的.

I have also used the random() function, and it's saying the same thing.

有人可以指导我该怎么做吗.

Can somebody please guide me on what to do?.

我有运行命令,例如:

composer dump-autoload

但是我遇到了同样的错误.

But I get the same error.

推荐答案

影响的可能性:高 Laravel 6升级指南

在Laravel 6中,所有 str _ array _ 帮助器都已移至新的 laravel/helpers Composer程序包中,并且已从框架.如果需要,您可以更新对这些助手的所有调用,以使用 Illuminate \ Support \ Str Illuminate \ Support \ Arr 类.另外,您可以将新的 laravel/helpers 包添加到您的应用程序中,以继续使用这些助手:

In Laravel 6 All str_ and array_ helpers have been moved to the new laravel/helpers Composer package and removed from the framework. If desired, you may update all calls to these helpers to use the Illuminate\Support\Str and Illuminate\Support\Arr classes. Alternatively, you can add the new laravel/helpers package to your application to continue using these helpers:

composer require laravel/helpers

如果不想添加包,则使用 Str Arr 类.

If don't want to add Package then Used Str And Arr Classes.

例如:

Str::random(12)

https://laravel.com/docs/master/helpers#method-随机

这篇关于将Laravel从5.6升级到6.0后,对未定义的str_random()函数的调用不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆