S
S
straengel2016-03-18 16:16:01
Yii
straengel, 2016-03-18 16:16:01

How to create an admin in Yii2 base version without unnecessary downloads and so on?

controllers were generated using GRUD, I'm trying to separate the main part of the site and create an admin panel. in /controllers there is an admin controller that is responsible for authorization, when going to site.ru/admin/ everything is fine. There is a popochka /controllers/admin in which there are controllers for managing records, when I try to enter the management of any records, I get a 404 error. I tried to prescribe echens in the admin controller - it seems to work, but I don’t want to create a thick controller. I believe that the truth is somewhere nearby, but only where?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vitaly Khomenko, 2016-03-18
@straengel

You have an AdminController controller at the root of the controllers folder and the rest of the controllers in the admin folder. When requesting the /admin/* URL, I suspect that the system is trying to find action methods in the AdminController controller, while ignoring all other controllers in the admin folder.
You need to move the AdminController to the admin folder, rename it to something like AuthController and write a rule for the UrlManager. The rule should look like this: '/admin' => 'admin/auth/login'. Now all requests to the /admin URL will be redirected to the AuthController controller, to the login action method. And visually it will be exactly the way you want.

S
shamyyl, 2016-03-18
@shamyyl

You create an admin module, in which you make several controllers

S
straengel, 2016-03-19
@straengel

Thank you, you really opened your eyes, not so long ago I encountered Yii2, now a lot has become clear and everything worked out. Made according to the version by Vitaliy IIIFX Khomenko, I will try the first version in another place. Thanks for responding!

A
Alex, 2020-07-14
@web_alex_developer

There is a ready-made solution with the possibility of multilingual mode https://github.com/itstructure/yii2-admin-module

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question