laravel 找不到类“App\Http\Controllers\Session”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42885331/
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
Class 'App\Http\Controllers\Session' not found
提问by Sibasankar Bhoi
I'm new in laravel. Having problem to show session temporary flash message. Can not rescue from this error
我是 Laravel 的新手。显示会话临时 Flash 消息时出现问题。无法从这个错误中解救
Class 'App\Http\Controllers\Session' not found What to do?
找不到“App\Http\Controllers\Session”类怎么办?
回答by Alexey Mezenin
You can add use Session;
to the top of the class.
您可以添加use Session;
到类的顶部。
Or use full namespace, like \Session::
或者使用完整的命名空间,比如 \Session::
Or just use the session()
helper instead of the facade.
或者只是使用session()
助手而不是门面。
回答by Sibasankar Bhoi
Use this
用这个
use Illuminate\Support\Facades\Session;
回答by Raisa Hasan
Use Session at the head of your controller file
在控制器文件的头部使用 Session
use Session;
回答by Amr Aly
You just need to import session Facade:
您只需要导入会话 Facade:
use Illuminate\Support\Facades\Session;
or you can use the class like this :
或者你可以像这样使用这个类:
\Session::