Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

laravel - Lumen FatalErrorException in RedirectResponse.php line 75: Call to a member function flashInput() on null

Hi I got this errors in Lumen

FatalErrorException in RedirectResponse.php line 75: Call to a member function flashInput() on null

in RedirectResponse.php line 75

at Application->handleShutdown() in RegistersExceptionHandlers.php line 55

at Application->LaravelLumenConcerns{closure}()

Here the code which throws the error:

return redirect('formular')
    ->withErrors($validator)
    ->withInput();

The error comes from withInput()

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The error is happening because Lumen 5.2 does not support sessions. The withErrors() and withInput() methods attempt to set values on the session attribute on the redirector, but the session attribute is null.

From the Lumen 5.2 documentation on validation:

Lumen does not support sessions out of the box, so the $errors view variable that is available in every view in Laravel is not available in Lumen. The $this->validate helper will always return JSON responses with the relevant error messages when validation fails. If you are not building a stateless API that solely sends JSON responses, you should use the full Laravel framework.

Basically, if you're trying to use sessions, you're trying to use Lumen 5.2 in a way it was not intended. You should either be using Lumen 5.1, or using the full Laravel framework. You can read the release notes here on the philosophy change for Lumen 5.2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...