My new route is causing an error and I need help f

2019-09-06 21:38发布

问题:

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');