E
E
Evgeny Perin2015-03-19 21:38:11
Yii
Evgeny Perin, 2015-03-19 21:38:11

Logic of separating frontend and backend in Yii2 advanced?

Good evening! I know very little about frameworks, and in general I have practically no programming experience (I am engaged in layout). Now I'm learning the basics of programming, I've even mastered a bunch of new terms (composer, migrations, behaviors...). But there is very little information on Yii2 (especially advanced), there are not enough step-by-step manuals. But now the question is about something else ... In the advanced version, we have a strict division into frontend and backend. In which of these parts should you create models and controllers? After creating a model (for example, country) and creating crud in the backend, how to access from the frontend what was created for the backend? And in general, did I understand correctly that models and cruds are created in the backend, and in the front there is only access to them and pulling out information? Please help me understand the logic behind this division... Don't kick the newbie too hard

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentin Saik, 2015-04-01
@seoperin

If you need to work with models / forms both on the frontend and on the backend, then place them in the common / models folder, for example, the Users model with which you display a list of users, you will need it both in the frontend and in the admin panel, it should be placed in common, if you write, for example, the Comments model that will display comments on a specific post, but you will not display comments in the admin panel, then place this model in the frontend/models folder, it will be more convenient to connect ( use app/models/Comments; ) if you need to display some statistics only in the admin panel, then create models in the backend / models folder.
But nothing terrible will happen if you create a model in the wrong folder, you just need to change the connection path in the namespace. But with controllers it’s different here, you create them only in the right application, if you create a StatisticsController controller that will display some kind of statistics, then you need to put it in the backend, because you will go to it from the admin panel, but if you want something it was available from both admin and frontend - create 2 controllers. I hope everything is clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question