My new route is causing an error and I need help finding it

有些话、适合烂在心里 提交于 2019-12-12 02:56:11

问题


So the error I am getting is Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException.

Here is the route:

Route::get('/', 'AuthController@index');
Route::get('/login', 'AuthController@login');
Route::post('/login', ['before' => 'csrf', 'uses' => 'AuthController@authenticate']);
Route::get('/logout', 'AuthController@logout');

Route::group(['before' => 'auth'], function() {

$noIndex = [ 'except' => ['index'] ];
$noShow = [ 'except' => ['show'] ];

Route::get('/dashboard', 'PagesController@dashboard');

Route::get('/test', 'MessageController@index');

Here is the controller:

/**
 * Display a listing of the resource.
 * GET /test
 *
 * @return Response
 */
public function index()
{
    return View::make('test.index');
}

回答1:


Now that we have some more complete information regarding your routes.php setup, it's possible that the problem is due to the auth filter.

(I'm assuming you left off the final }); from your routes.php above.)

Try removing the before filter (or change it temporarily to ['before' => 'none']) and reload desk.dev:8000/test. Make sure you don't simply hit reload on the current error page, since it may be pointing to desk.dev:8000/login.

If your AuthController is not set up, or is missing the login method, you will get a NotFoundHttpException when the auth filter in filter.php tries to redirect to your login page, with:

return Redirect::guest('login'); 


来源:https://stackoverflow.com/questions/26040725/my-new-route-is-causing-an-error-and-i-need-help-finding-it

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