0

I just created a simple page in Laravel and when I run the file I got the error:

Target class [App\Http\Controllers\registerController] does not exist.

I attached the folder structure below:

enter image description here

routes

Route::get('/', [App\Http\Controllers\registerController::class, 'create']);

createUser.blade.php

<html>
<head>
</head>
<body>
<form method="post" action="{{url('create')}}">
{{csrf_field()}}
  <div class="container">
    <h1>Register</h1>
    <p>Please fill in this form to create an account.</p>
    <hr>

    <label for="email"><b>Email</b></label>
    <input type="text" placeholder="Enter Email" name="email" id="email" required>

    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" id="psw" required>

    <label for="psw-repeat"><b>Repeat Password</b></label>
    <input type="password" placeholder="Repeat Password" name="psw-repeat" id="psw-repeat" required>
    <hr>

    <p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
    <button type="submit" class="registerbtn">Register</button>
  </div>

  <div class="container signin">
    <p>Already have an account? <a href="#">Sign in</a>.</p>
  </div>
</form>
</body>
</html>

registerController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class register extends Controller
{
    public function create()
    {
        return view('createUser');
    }
}

1 Answer 1

2

Your file name and the class name doesn't match. Modify your registerController.php file as follows;

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class registerController extends Controller
{
    public function index()
    {
        return view('index');

    }
}

And regarding the naming classes, I recommend using Capital camel case.

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

2 Comments

no sir it is getting same error.Target class [App\Http\Controllers\registerController] does not exist
Change the name into RegisterController for both filename and class name and then run composer dump-autoload.

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.