0
votes

Good Afternoon, I donĀ“t understand this exception

ReflectionException in Container.php line 737: Class app\Http\Controllers\Login\LoginController does not exist

I know thats is related with the namespace but i configured my composer.json autoload. When i changed it to app\Http\Controllers\Login it works ok. I also did artisan clear-compiled and composer dump-autoload

My Class is like this

<?php

namespace Login;

use Controller;
use Validator;
use Input;
use Auth;
use Redirect;
use View;

class LoginController extends Controller{}

My composer.json autoload

"autoload": {
 "classmap": 
  [ "app/Http/Controllers" , "app/Models" , "database" ],
 "psr-4": {
  "app\\": "app/" 
 }
},

My Controllers Directory is like this

- app
-- Http
--- Controllers
---- Login
----- LoginController.php
-- Models
--- User
---- User.php

Thanks in advance

Edit: Why i don't have problems with my model files when i use a namespace like this:

namespace User;

In my config auth i have this:

'model' => User\User:class,

1

1 Answers

2
votes

Your controller is in Login namespace, while it should be in app\Http\Controllers\Login namespace.

No entries in composer.json can change the way PHP's namespaces work - the mapping in there can just be used to tell autoloader where to look for physical files from given namespace.