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

痴心易碎 提交于 2019-12-02 11:06:39

问题


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->Laravel\Lumen\Concerns{closure}()

Here the code which throws the error:

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

The error comes from withInput()


回答1:


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.



来源:https://stackoverflow.com/questions/35456716/lumen-fatalerrorexception-in-redirectresponse-php-line-75-call-to-a-member-func

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!