繁体   English   中英

Laravel whoops 和 class str 未找到

[英]Laravel whoops and class str not found

我试图将我的 Laravel 从 5.4 更新到 5.5,但我遇到了一些错误-

未捕获的错误:调用未定义的方法 Whoops\\Handler\\PrettyPageHandler::setApplicationPaths() in...

Laravel 日志显示如下内容-

production.ERROR: Class 'str' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'str' not found at C:\\xampp\\htdocs\\teste \\config\\cache.php:91) [堆栈跟踪]

production.ERROR: Class 'str' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'str' not found at C:\\xampp\\htdocs\\teste \\config\\cache.php:91) [堆栈跟踪]

这就是我的 cache.php 的样子-

'prefix' => env(
    'CACHE_PREFIX',
    str::slug(env('APP_NAME', 'laravel'), '_').'_cache'
 ),

第 91 行是 str::slug。 知道我错过了什么吗?

您需要像以下之一一样更改字符串函数调用-

str_slug('your_string');

或这个

use Str;

Str::slug('your_string');

一旦您对配置文件进行更改,请确保运行它,以便您的配置更改可以再次缓存并按预期工作 -

php artisan config:cache

要在刀片模板中使用Str ,您可以添加到app.php

class_alias('Illuminate\Support\Str', 'Str');

或者对于config/app.php别名部分的较新版本

'Str' => Illuminate\Support\Str::class,

{{ Str::slug('your_string') }}变为可用/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM