R
R
Roman2019-02-16 22:36:56
Laravel
Roman, 2019-02-16 22:36:56

What is the complete sequence of actions to put a part of Laravel controllers in a separate folder?

Hello. I placed the MyController
controller in the /app/Http/Controllers/Admin folder in the route, as in the manual:

Route::get('/admin/my', 'Admin\[email protected]');

it now writes to me:
ReflectionException (-1)
Class App\Http\Controllers\Admin\MyController does not exist

what and where you need to register so that everything works as it should // a link to the manual is welcome)) this is just the same case)))
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2019-03-02
@procode

Solved the problem, maybe someone will come in handy.
If you just change the namespace in the controller itself, then it starts writing this:
that is, it can't find the Controller base class, and we need to add one more line: then it starts to see both our controller and the Controller base class, hooray! Now I can shove controllers into separate folders in Laravel!))

J
jazzus, 2019-02-16
@jazzus

Perhaps moved to a folder, but did not register the path at the top of the controller namespace App\Http\Controllers\Admin;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question