Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uccdev's avatar

Laravel confused about where to find Auth files when I call "php artisan route:list"?

I'm setting up my laravel project for login and registration. I've run the npm install dev && npm run dev and gotten all the required files. I have my relevant controllers like LoginController inside the App\Http\Controllers\Auth\LoginController directory (that part is important).

I've also set up a populated SQLite database, with an Admin model. So I try to run a simple php artisan route:list command.

And that's when I get this error:

 Target class App\Http\Controllers\Admin\Auth\LoginController] does not exist.

Now I do have a LoginController, but the App\Http\Controllers\Admin directory doesn't exist. So I create one, then I cut my Auth folder and paste it into the App\Http\Controllers\Admin point. Instead I get this error:

 ErrorException: include(/home/.../Controllers/Auth/LoginController.php): failed to open stream: No such file or directory``

So it needs both folders and directories to exist? Fine. I make a copy of the Auth folder in its original location. So now I have two Auth folders with the same controllers:

App\Http\Controllers\Admin\Auth App\Http\Controllers\Auth

And I run the route:list command again. What do I get?

 FatalErrorException: Cannot declare class App\Http\Controllers\Auth\LoginController, because the name is already in use.``

I seem to be trapped in a circle! Help?

0 likes
3 replies
jlrdw's avatar

As I said in your other post you have to follow the chapter on Authentication.

Copying a missing file from the Repository that wasn't properly scaffolded is not going to fix the problem.

Nakov's avatar
Nakov
Best Answer
Level 73

@uccdev do you have the correct namespace in the files?

2 likes
uccdev's avatar

I had actually forgotten to update the namespace in the Admin folder, my mistake. Thankfully that error is now fixed!

Please or to participate in this conversation.