Laravel can’t find my class

Asked

Viewed 417 times

0

I have a controller that is located in:

app/Http/Controllers/Auth/LoginController that has the login function.

I created a route in my api.php for when to login access my method:

Route::post('login', 'Auth\LoginController@login');

My login controller:

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller

...

I get:

Class 'App Http Controllers Auth Auth' not found"

If I change course and leave only:

Route::post('login', 'LoginController@login');

I get:

"Class App Http Controllers Logincontroller does not exist"

I would like to know how to fix this and why the Laravel is so bad with the location of the files?

  • Are the folders structured correctly? The composer.json is configured correctly?

  • I have a Registercontroller class in the same directory as this Logincontroller class. Scalable finds registercontroller but does not find logincontroller

  • Use the command composer dump-autoload or use the parameter namespace, for example: Route::namespace('Auth')->group(function () {
 // Load Controllers "App\Http\Controllers\Auth"
});

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.