0

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
4
  • did you rename your Controller to RegisterController in other words is Controller.php in the app/Http/Controllers folder? Commented Apr 6, 2018 at 12:44
  • Uncomment //use App\RegisterController Commented Apr 6, 2018 at 12:44
  • use App\Http\Controllers\Controller add this line Commented Apr 6, 2018 at 12:56
  • did you rename your Controller to RegisterController ? No, the controller is in the place Commented Apr 7, 2018 at 0:59

3 Answers 3

1

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!

Sign up to request clarification or add additional context in comments.

Comments

0

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";
    }
}

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.