xenish
xenish

Reputation: 1424

Separate folders for controller

I want to separate my controllers into two different folders BackEnd and FrontEnd, but when I do it shows an error: Class App\Http\Controllers\CredentialsController does not exist. This credentialscontroller is inside BackEnd folder so I changed the namespace to namespace App\Http\Controllers\BackEnd; and also added use App\Http\Controllers\Controller; so that it still extends the base controller in the CredentialsController then I used composer dump-autoload but it's still not working. It shows the same error. Also I have tried adding this to my composer.json just to check if it works and it still throws the same error.

 "autoload": {
          "files": [
           "App\Http\Controllers\BackEnd\CredentialsController.php"
         ]
     },

All I want to do is separate my controllers for BackEnd and FrontEnd.

Upvotes: 1

Views: 93

Answers (2)

RKJ
RKJ

Reputation: 51

You must include Namespace in route, namespace are mapped as folder path Route::resource('credentials', 'BackEnd\CredentialsController');

Upvotes: 0

lukasgeiter
lukasgeiter

Reputation: 152860

You probably still have to adjust the namespace where you actually use the controller.

For example in a route:

Route::resource('credentials', 'BackEnd\CredentialsController');

Upvotes: 2

Related Questions