找不到Laravel呐喊和class str

时间:2019-03-03 22:03:11

标签: php laravel

我试图将Laravel从5.4更新到5.5,但是出现一些错误-

  

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

Laravel日志显示如下内容-

  

production.ERROR:未找到类'str'{“ exception”:“ [对象]   (Symfony \ Component \ Debug \ Exception \ FatalThrowableError(代码:0):   找不到“ str”类   C:\ xampp \ htdocs \ teste \ config \ cache.php:91)[stacktrace]

     

production.ERROR:未找到类'str'{“ exception”:“ [对象]   (Symfony \ Component \ Debug \ Exception \ FatalThrowableError(代码:0):   找不到“ str”类   C:\ xampp \ htdocs \ teste \ config \ cache.php:91)[stacktrace]

这是我的cache.php的外观-

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

第91行是str :: slug。知道我想念什么吗?

2 个答案:

答案 0 :(得分:1)

您需要像以下其中一种那样更改字符串函数调用-

str_slug('your_string');

或者这个

use Str;

Str::slug('your_string');

确保在配置文件中进行更改后立即运行此配置,以便可以再次缓存配置更改并按预期工作-

php artisan config:cache

答案 1 :(得分:0)

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

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

,或者在config/app.php

中使用新版本的别名部分
'Str' => Illuminate\Support\Str::class,

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