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

$filename = str_random(12);

我收到以下错误.

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

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

有人能指导我做什么吗?

I have run commands like:

composer dump-autoload

But I get the same error.

推荐答案

Likelihood Of Impact: High Laravel 6 Upgrade Guide

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

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

例如:

Str::random(12)

https://laravel.com/docs/master/helpers#method-str-random

Laravel相关问答推荐

如何将错误从laravel恢复到inertiajs/vue 3应用程序?

CKEditor在laravel中的p标记之前和之后添加额外的p标记

为什么我的 Laravel 开发服务器不提供 public 文件夹下的文件?

Laravel Homestead vagrant up 超时

Laravel 5.3:语法错误或访问冲突:1463 HAVING 子句中使用了非分组字段距离

Laravel 5 - 手动分页

Laravel 5 日志(log)中的最大文件数

Laravel 5.1 是否与 PHP 7 兼容

Laravel - 排序的集合输出不是数组

为什么人们将 .env 放入 gitignore?

Laravel 5:在同一字符串上使用 bcrypt 给出不同的值

Heroku CLI 安装错误:PATH 未更新,原始长度 1585 > 1024

在 Laravel 5 中找不到类App\Http\Controllers\Artisan

嘲笑没有匹配的关闭处理程序

找不到框laravel/homestead

Laravel 4 验证唯一(数据库)忽略当前

Laravel 隐藏属性.例如密码 - 安全

如何卸载 Laravel Passport

如何在 Laravel 中动态更改 .env 文件中的变量?

Laravel 5.3 - 用户Collection 的单一通知(关注者)