• Register
0 votes

Problem :

I want to get something very basic running. I am used to the CI and now learning the Laravel 4, and their docs are not making it easy! Anyways, I want to create the login form and just make sure that the data is posted successfully by printing it in a next form. But I am getting below exception:

“Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException”

 Any help in resolving above error will be greatly appreciated.

7 5 2
3,870 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

You are facing that error as you are posting to the GET route.

I want to split your routing for validate into the separate GET and POST routes as shown below :

The New Routes:

Route::post('validate', 'MemberController@validateCredentials');
Route::get('validate', function () {
return View::make('members/login');

Then your controller method could just be as shown below

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


Typically the MethodNotAllowedHttpException happens only when the

route method does not match.

Suppose you have defined POST request route file, however you are sending GET request to a route.

I know above given solutions will help you in resolving all the errors.

9 7 4
38,600 points
0 votes


You are obtaining that error since you are posting to a GET route.

I would interrput your routing for validate into a separate GET and POST routes.

New Routes:

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

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

Thereafter your controller method could only be

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

My doubt is the problem lies in your route definition.

You identified the route as a GET request however the form is possibly sending a POST request. Alter your route definition.

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

It's usually better practice to use named routes (uses to scale in case the controller method/class changes).

Route::post('/validate', array(
    'as' => 'validate',
    'uses' => 'MemberController@validateCredentials'

In the form employ the following

<?php echo Form::open(array('route' => 'validate')); ?>

The issue is the you are employing POST however really you have to perform PATCH To solve this add

<input name="_method" type="hidden" value="PATCH">

Only after the Form::model line

I encountered this issue as well and the other answers here were useful, however I am using a Route::resource which takes care of GETPOST, and other requests.

In my instance I left my route as is:

Route::resource('file', 'FilesController');

And easily modified my form to submit to the store function in my FilesController

{{ Form::open(array('route' => 'file.store')) }}

This solved the issue, and I thought it was worth pointing out as a separate answer whereas several other answers point out including a new POST route. This is an option however it's not required.

That is since you are posting data through a get method.

Instead of

Route::get('/validate', 'MemberController@validateCredentials');

Attempt this

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


10 6 4
31,120 points

Related questions

0 votes
2 answers 334 views
Problem : I am facing following error while trying to login from the form: Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message The following is my route: Route::get('/', ['as' => '/', 'uses' => 'LoginController@getLogin']); Route::get('/login', ... ']); }); The following is form tag: <form class="login-form" action="{{ route('login') }}" method="post">
asked Dec 3, 2019 alecxe 7.5k points
1 vote
1 answer 334 views
Problem: I am very new to Laravel. I have recently started leaning laravel. I am using the correct email address. I have already echoed it but if I try to send it then I face the below error: "Address in mailbox given [] does not comply with RFC 2822, 3 ... send('emails.activation', $data, function($message){ $message->to($email)->subject($subject); }); ->with('title', "Registered Successfully.");
asked Jun 5, 2020 Martin K 6.6k points
0 votes
1 answer 10 views
Problem: How to get rid of the error:failed opening required 'vendor/autoload.php'?
asked Dec 13, 2020 prog_learner 2.5k points
0 votes
1 answer 10 views
Can anyone help me in some interview questions all related to Laravel thanks!!
asked Dec 10, 2020 Lucky Guy 930 points
0 votes
1 answer 178 views
Problem: What is $_server['http_referer']? How can we use $_server['http_referer'] in laravel php.
asked Nov 16, 2020 prog_learner 2.5k points
0 votes
1 answer 7 views
Problem So I have following method that draws input fields according to specified value: function drawInputs() { let type = reCalcType.options[reCalcType.selectedIndex].value; let container = document.getElementById("form_inputs"); let fields = getInputsArr(type); ... validation error: P.S. Old values are correct and displayed on console.log and they initialized before calling drawInputs function
asked Sep 14, 2020 Marivoke 530 points
0 votes
0 answers 52 views
I'm applying Laravel to write a service for mobile. I am trying to figure the solution. Can someone give me the hint?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 61 views
I'm a newbie when it comes to Linux administration using bash... I was following a tutorial on how to install laravel 5.2 from here... installed it successfully... firstly I installed composer and ran the following command composer global require "laravel/installer" after this put ... the path Note: I have installed oh my zsh on my terminal... What do I have to do to get it working please help
asked Sep 13, 2020 Marivoke 530 points