2016-04-15 6 views
3

Я новичок в Lumen и я пытаюсь настроить аутентификацию с помощью oauth2 с this tutorial , когда я пытаюсь получить доступ к любому маршруту, я получил эту ошибку:Lumen: Класс Осветите Cookie Middleware AddQueuedCookiesToResponse не существует

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 

самозагрузки \ 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','[email protected]'); 
} 
+0

Вы установили 'загореться/cookie' пакет? – Alfa

ответ

1

Просто запустите

composer require illuminate/cookie

Затем добавьте этот код начальной загрузки/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