Laravel 5.3身份验证检查-未根据请求设置会话存储

Laravel 5.3身份验证检查-未根据请求设置会话存储,laravel,laravel-5.3,Laravel,Laravel 5.3,我将在5.3中启动一个新的应用程序,并希望实现如上所述的身份验证检查解决方案 我正在使用5.3版的注册和登录模型。我在Laravel上只工作了一个月,所以很难完全解释这个解决方案。 我将HomeController.php移动到controllers下的Auth文件夹,并添加了以下use语句:use-App\User; 使用Illumb\Support\Facades\Auth; 我编辑了HomeController构造函数,如下所示: public function __construct()

我将在5.3中启动一个新的应用程序,并希望实现如上所述的身份验证检查解决方案

我正在使用5.3版的注册和登录模型。我在Laravel上只工作了一个月,所以很难完全解释这个解决方案。 我将HomeController.php移动到controllers下的Auth文件夹,并添加了以下
use
语句:
use-App\User;
使用Illumb\Support\Facades\Auth;
我编辑了HomeController构造函数,如下所示:

public function __construct()
{
    //$this->middleware('auth');
    $this->middleware(function ($request, $next) {
        $this->user= Auth::user();
        return $next($request);
    });
}
这是我的控制器截图

仍然获取“会话存储未按请求设置”。尝试注册时出错。 我也读书,但需要更多的指导。只想让5.3开箱即用的身份验证开始工作。 这是我的Auth文件夹结构

这是我的路线/web.php

RouteServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
 protected $namespace = 'App\Http\Controllers';

/**
 * Define your route model bindings, pattern filters, etc.
 *
 * @return void
 */
public function boot()
{
    //

    parent::boot();
}

/**
 * Define the routes for the application.
 *
 * @return void
 */
public function map()
{
    $this->mapApiRoutes();

    $this->mapWebRoutes();

    //
}

/**
 * Define the "web" routes for the application.
 *
 * These routes all receive session state, CSRF protection, etc.
 *
 * @return void
 */
protected function mapWebRoutes()
{
    Route::group([
        'middleware' => 'web',
        'namespace' => $this->namespace,
    ], function ($router) {
        require base_path('routes/web.php');
    });
}

/**
 * Define the "api" routes for the application.
 *
 * These routes are typically stateless.
 *
 * @return void
 */
protected function mapApiRoutes()
{
    Route::group([
        'middleware' => 'api',
        'namespace' => $this->namespace,
        'prefix' => 'api',
    ], function ($router) {
        require base_path('routes/api.php');
    });
}
}

您的RouteServiceProvider.php文件看起来像什么?因为我知道可能是什么问题。那是错误的文件。你的应用程序/提供商/文件夹中应该有一个。没问题。你的app/Http/Kernel.php文件呢?嗯。它不是我想象的那样(内核中缺少中间件组)。你还在犯错误吗?是的,还是。非常确定它与此相关,但不知道如何实现建议的解决方案。RouteServiceProvider.php文件看起来像什么?因为我知道可能是什么问题。那是错误的文件。你的应用程序/提供商/文件夹中应该有一个。没问题。你的app/Http/Kernel.php文件呢?嗯。它不是我想象的那样(内核中缺少中间件组)。你还在犯错误吗?是的,还是。很确定这与此相关,但不知道如何实施建议的解决方案。
<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
/**
 * The application's global HTTP middleware stack.
 *
 * These middleware are run during every request to your application.
 *
 * @var array
 */
protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,                    
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        'throttle:60,1',
        'bindings',
    ],
];

/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
    'can' => \Illuminate\Auth\Middleware\Authorize::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}