流明:类 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse 不存在

Posted

技术标签:

【中文标题】流明:类 Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse 不存在【英文标题】:Lumen: Class Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse does not exist流明:类 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse 不存在 【发布时间】:2016-08-07 04:16:06 【问题描述】:

我是 Lumen 的新手,我正在尝试使用带有 this tutorial 的 OAuth2 设置身份验证 当我尝试访问任何路线时出现此错误:

ReflectionException in Container.php line 738:
Class Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse does not exist

in Container.php line 738
at ReflectionClass->__construct('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse') in Container.php line 738
at Container->build('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', array()) in Container.php line 633
at Container->make('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', array()) in Application.php line 205
at Application->make('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse') in Pipeline.php line 123
at Pipeline->Illuminate\Pipeline\closure(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\closure(object(Request)) in OAuthExceptionHandlerMiddleware.php line 36
at OAuthExceptionHandlerMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(OAuthExceptionHandlerMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\closure(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\closure(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in RoutesRequests.php line 626
at Application->sendThroughPipeline(array('LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse'), object(Closure)) in RoutesRequests.php line 382
at Application->dispatch(object(Request)) in RoutesRequests.php line 327
at Application->run(object(Request)) in index.php line 28

bootstrap\app.php

$app->middleware([
    'LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware',
    'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse'  // <--- added
]);

$app->routeMiddleware([
    'check-authorization-params' => 'Optimus\OAuth2Server\Middleware\CheckAuthCodeRequestMiddleware',
    'csrf' => 'Laravel\Lumen\Http\Middleware\VerifyCsrfToken',
    'oauth' => 'Optimus\OAuth2Server\Middleware\OAuthMiddleware',
    'oauth-owner' => 'Optimus\OAuth2Server\Middleware\OAuthOwnerMiddleware'
]);

$app->register(App\Providers\EventServiceProvider::class);
$app->register('LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider');
$app->register('Optimus\OAuth2Server\OAuth2ServerServiceProvider');

routes.php

$app->group(['prefix' => 'v1','namespace' => 'App\Http\Controllers'], function($app)

    $app->get('post','PostController@index');

【问题讨论】:

你安装illuminate/cookie包了吗? 【参考方案1】:

直接跑吧

作曲家需要照明/cookie

然后在 bootstrap/app.php 中添加这段代码

$app->singleton('cookie', function () use ($app) 
    return $app->loadComponent('session', 'Illuminate\Cookie\CookieServiceProvider', 'cookie');
);

$app->bind('Illuminate\Contracts\Cookie\QueueingFactory', 'cookie');

参考https://github.com/esbenp/lumen-api-oauth/issues/23

【讨论】:

以上是关于流明:类 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse 不存在的主要内容,如果未能解决你的问题,请参考以下文章

流明:全新安装时找不到 App\Http\Controllers\Controller 类

在流明中找不到类“验证器”

在流明中包括 laravel 5 包

如何在流明 5.2 中设置时区?

怎么看投影机真实ISO流明?

软删除是不是适用于流明框架?流明的限制?