Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拉维尔';s Auth::user()返回null_Php_Laravel_Module - Fatal编程技术网

Php 拉维尔';s Auth::user()返回null

Php 拉维尔';s Auth::user()返回null,php,laravel,module,Php,Laravel,Module,我像这样改变了我的Laravel文件结构 我不会讨论它是如何长的,但一切正常,现在如果我想从新的控制器、视图或模型位置访问Auth::user()或Auth中的任何内容,它将返回错误或null,当我从routes/web.php访问Auth时,它工作正常,因此我的新配置中的某些东西缺少如何修复它的想法?任何文件代码都需要,请让我把它写下来,谢谢。谢谢Thanx给我的“提示”,但我找到了答案。 我只需要在我的User/routes.php中添加web中间件,如下所示: Route::group(

我像这样改变了我的Laravel文件结构

我不会讨论它是如何长的,但一切正常,现在如果我想从新的控制器、视图或模型位置访问Auth::user()或Auth中的任何内容,它将返回错误或null,当我从routes/web.php访问Auth时,它工作正常,因此我的新配置中的某些东西缺少如何修复它的想法?任何文件代码都需要,请让我把它写下来,谢谢。

谢谢Thanx给我的“提示”,但我找到了答案。 我只需要在我的User/routes.php中添加web中间件,如下所示:

Route::group(['prefix' => 'users', 'namespace' => 'App\Modules\User\Controllers'], function(){
    Route::get('/profile', ['as' => 'profile', 'uses' => 'UsersController@profile'])->middleware('web');
           );

web.php
从提供会话的RouteServiceProvider应用了
web
中间件组。需要了解您实际在做什么。欢迎使用堆栈溢出!请选择并编辑您的问题,以直接显示图像,而不是作为链接。请同时显示您收到的错误,最好是文本。我只是将我的应用程序文件结构划分为模块,这样每个模块都有自己的控制器模型视图文件结构对不起,我只是新来的,不允许直接放置图片…如果我访问Auth::User()需要更多的XPsok以便从User/views/profile.blade.php获得它返回与控制器相同的null