Answer the question
In order to leave comments, you need to log in
Yii best practice?
Hello, you need to quickly get into YII, although the documentation is excellent, YII is somewhat different from other frameworks and it is not very clear how to structure the project at all.
1 When should you use Components, Modules, Widgets, and how to put it all together?
2 As far as I understand YII, you first need to create tables in the database, then on their basis, using gii, you can generate models, controllers, CRUD. Whether it is possible to make so that tables in a DB were created automatically, on the basis of the same models? What is the best way to do this?
3 YII is very flexible, there are many options to do the same thing, but how to organize the directory structure well? what functionality where to take out?
Answer the question
In order to leave comments, you need to log in
A component is a php class with some functionality, a widget is a set of components + html code, a module is a separate section on the site, for example, an account. like so in the first yii was. In the second, I don’t know, but personal IMHO it’s better not to use the first one anymore, it’s not very flexible. What is actually flexible is Symfony2 , but it will also be more difficult to learn. In favor of the symphony, I will say that there is an automatic generation of tables in the database based on models + migrations.
study yii2 and see application examples in official. repositories.
To begin with, I advise this structure https://github.com/yiisoft/yii2-app-basic
I usually create modules for news, for a blog, for a store, for pages, etc. This is very convenient and you can connect them to other sites in the future.
I advise you to study migrations. With the help of gii, I generate models, controllers, but then of course I change a lot of things there to suit my needs.
I usually create components and widgets in modules. Well, behavior is a very powerful thing. I advise you to look at them and study.
And one more project organization structure from the developers https://github.com/yiisoft/yii2-app-advan . A very powerful and flexible thing, but it seems to me that it is mainly intended for large projects.
Here is another demo bloghttps://github.com/vova07/yii2-start . There's a lot of useful stuff in there.
Whether it is possible to make so that tables in a DB were created automatically, on the basis of the same models?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question