1
votes

I defined a controller LoginController but I am having this error?

ReflectionException in Route.php line 264: Class App\Http\Controllers\LoginController does not exist

class LoginController extends Controller {

  // Display the login form
  public function showLogin()
  {
    return View::make('login');
  }

  // Process submission of the login form by verifying user’s credentials
  public function processLogin()
  {
    $username = Input::get('username');
    $password = Input::get('password');
    if ($username === 'prince' && $password === 'c@spiAN') {
      return 'Access granted!';
    } else {
      return 'Access denied! Wrong username or password.';
    }
  }
}
2
Did you put a namespace ("namespace App\Http\Controllers") in your controller? Can you please update the full code for your controller?John Roca

2 Answers

2
votes
<?php namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\User;

class LoginController extends Controller {
// Display the login form
public function showLogin()
{
  return View::make('login');
}

// Process submission of the login form by verifying user’s credentials
public function processLogin()
{
  $username = Input::get('username');
  $password = Input::get('password');
  if ($username === 'prince' && $password === 'c@spiAN') {
    return 'Access granted!';
  } else {
  return 'Access denied! Wrong username or password.';
  }
 }
}
0
votes

Reinstalling laravel fixed the error without even adding anything.