$app->get('/', function() use ($app) { return $app->welcome(); }); 有问题

lumen
里 的初始画面

$app->get('/', function() use ($app) {
return $app->welcome();
});

有点小问题,

app.php 去掉middleware 的注释之后:

$app->middleware([
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
//'Laravel\Lumen\Http\Middleware\VerifyCsrfToken',
]);

// $app->routeMiddleware([

// ]);

访问网站首页报错:

ErrorException in StartSession.php line 175:
Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, string given, called in /usr/html/lumen/vendor/illuminate/session/Middleware/StartSession.php on line 72 and defined
in StartSession.php line 175
at Application->Laravel\Lumen{closure}('4096', 'Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, string given, called in /usr/html/lumen/vendor/illuminate/session/Middleware/StartSession.php on line 72 and defined', '/usr/html/lumen/vendor/illuminate/session/Middleware/StartSession.php', '175', array()) in StartSession.php line 175
at StartSession->addCookieToResponse('<html> <head> <title>Lumen</title> <link href='//fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'> <style> body { margin: 0; padding: 0; width: 100%; height: 100%; color: #B0BEC5; display: table; font-weight: 100; font-family: 'Lato'; } .container { text-align: center; display: table-cell; vertical-align: middle; } .content { text-align: center; display: inline-block; } .title { font-size: 96px; margin-bottom: 40px; } .quote { font-size: 24px; } </style> </head> <body> <div class="container"> <div class="content"> <div class="title">Lumen.</div> </div> </div> </body> </html> ', object(Store)) in StartSession.php line 72
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Application.php line 1317
at Application->sendThroughPipeline(array('Illuminate\Cookie\Middleware\EncryptCookies', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', 'Illuminate\Session\Middleware\StartSession', 'Illuminate\View\Middleware\ShareErrorsFromSession'), object(Closure)) in Application.php line 1099
at Application->dispatch(null) in Application.php line 1037
at Application->run() in index.php line 28

后来把
//$app->get('/', function() use ($app) {
// return $app->welcome();
//});

改成 $app->get('/', function(){ return $view = view('lumen') ; } );

就好了
已邀请:

要回复问题请先登录注册