M
M
Mikha Pankratov2015-03-15 18:00:45
PHP
Mikha Pankratov, 2015-03-15 18:00:45

How to properly use Controllers in yii2?

Hello everyone, sorry for such a childish question :)
Well, I think it's better to ask than to make a shed ...
my structure


controllers\sitedefault
controllers\comments\CommentsController
controllers\photo\PhotoController
models\comments\commentsUser
models\comments\commentsVk
controllers\photo\PhotoUser
controllers\photo\PhotoVk

I divide by folders to make it easier to find the desired file.
How are you?
And another question,
How to route to this controllery (controllers\comments\CommentsController ) or how to call it in siteControllers and is it worth it? Where is the best place to call to collect everything I need?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Lavrentiev, 2015-03-17
@frmax

Yes, that's right, you can have your controllers with such a structure. This option is described in the standard documentation and there are examples of accessing controllers. www.yiiframework.com/doc-2.0/guide-structure-contr...
I think it's more a matter of taste as you like, someone prefers to make modules, someone scatters it in directories, and someone just pours everything into controllers .

S
Sergey Semenko, 2015-03-15
@abler98

Is that even possible? In my opinion, all controllers should be in the same folder, in your case it would be better to divide the site into modules.

M
Mikha Pankratov, 2015-03-15
@frmax

I have seen such a structure. The question is thinking about religion although I may be wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question