php

Solved – Laravel Throwing MethodNotAllowedHttpException

Problem

If you are getting similar messages with the exception

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

The problem is usually that you haven’t specified the proper route type.

You are getting that error because you might be posting to a GET route.

Try splitting your routing for into a separate GET and POST routes.

Solution

New Routes:

Route::post('validate', 'MemberController@validateCredentials');

Route::get('validate', function () {
    return View::make('members/login');
});

Then your controller method could just be

public function validateCredentials()
{
    $email = Input::post('email');
    $password = Input::post('password');
    return "Email: " . $email . " and Password: " . $password;
}

About the author

laravelrecipies