Realalun
Realalun

Reputation: 35

cant find "Class 'App\Http\Controllers\Controller' not found" on laravel 5.4

i have an issue with my laravel project currently i been working the register page, but it stuck at class controller not found enter image description here

here's my route script

Route::get('/', function() {
    return view('home');
});

Route::get('/signin', function() {
    return view('login');
});

Route::get('/register', function() {
    return view('register.register');
});

Route::post('/register_action','RegisterController@store');

the RegisterController script

<?php

namespace App\Http\Controllers;
//use App\RegisterController;


use Illuminate\Http\Request;

class RegisterController extends Controller
{
    //

    public function store(){
        echo "test";
    }
}

and view register blade

@extends('layout');

@section('content')

<h2>Vertical (basic) form</h2>
  <form action="/register_action" method="post">

    <input type="hidden" name="_token" value="{{csrf_token()}}">

    <div class="form-group">
      <label for="name">Name:</label>
      <input type="name" name="username" class="form-control" id="name" placeholder="Enter Name">
    </div>
    <div class="form-group">
      <label for="email">Email:</label>
      <input type="email" name="email" class="form-control" id="email" placeholder="Enter email">
    </div>
    <div class="form-group">
      <label for="pwd">Password:</label>
      <input type="password" name="password" class="form-control" id="pwd" placeholder="Enter password">
    </div>
     <div class="form-group">
      <label for="pwd"Confirm >Password:</label>
      <input type="password" name="cpassword" class="form-control" id="pwd" placeholder="Confirm password">
    </div>
    <div class="checkbox">
      <label><input type="checkbox" name="remember"> Remember me</label>
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
  </form>

@endsection

Upvotes: 0

Views: 1687

Answers (3)

abubakkar tahir
abubakkar tahir

Reputation: 847

Hello guys you need to write the below one line of code into your

protected $namespace = 'App\Http\Controllers';

app\providers\RouteServiceProvider.php file.
 
 

and then you can access controller into web.php file

Upvotes: 0

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

You should try this:

<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class RegisterController extends Controller
{
    //

    public function store(){
        echo "test";
    }
}

Upvotes: 0

NotSoSnake
NotSoSnake

Reputation: 46

Check if Http/Controllers/Controller.php exists in your project.

If not, just create it, copy-paste this code and save:

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

Let me know if it works!

Upvotes: 1

Related Questions