php - Symfony Component HttpKernel Exception MethodNotAllowedHttpException. What is the cause?


I'm quite new to Laravel and I'm facing a vague error. Whenever I try to login with an username and password, I get this error.

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

My code consists of this:



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\User;

class UserController extends Controller
    public function postSignUp(Request $request){
        $firstName = $request['firstName'];
        $lastName = $request['lastName'];
        $username = $request['username'];
        $password = bcrypt($request['password']);
        $email = $request['email'];

        $user = new User();
        $user->first_name = $firstName;
        $user->last_name = $lastName;
        $user->username = $username;
        $user->password = $password;
        $user->email = $email;



        return redirect()->back();

    public function postSignIn(Request $request){
        $username = $request['username'];
        $password = $request['password'];
        if (Auth::attempt(['username' => $username, 'password' => $password])){
            return redirect()->back();

Provider called User.php


namespace App;

use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Authenticatable
    use \Illuminate\Auth\Authenticatable;

Route file web.php


Route::get('/', '[email protected]')->name('home');
Route::post('signup', '[email protected]')->name('signup');
Route::get('signin', '[email protected]')->name('signin');



MethodNotAllowed means that you are using a VERB that the webserver didn't like for that request... i.e. GET instead of POST.

Your controller for sign-in is calledpostSignIn but I notice that you are calling it with aget




It’s because the route doesn’t exist. Add the sign in post route. postSignin should be a post route

Route::post('signin', '[email protected]')->name('signin');

Route::get('signin', '[email protected]')->name('signInForm');

Instead of

Route::get('signin', '[email protected]')->name('signin’);

People are also looking for solutions to the problem: javascript - PHP $_GET and underlines


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.