N
N
Nik Gubin2017-02-12 21:02:48
Yii
Nik Gubin, 2017-02-12 21:02:48

Is there any point in templating in Yii2?

Good evening, colleagues. Now I'm actively studying Yii2 and I have a lot of questions.
Here's another example: does it make sense to use a template engine (Twig or Smarty, or another)?
Why am I asking. If you use Smarty, then in layouts and views you no longer see hints from the IDE (which is not the most important thing), you no longer see the point in inheritance, because the main layout changes from the controller.
If one of you uses a template engine, then tell me what advantages it gives you? I would like to use it in a project in order to learn Smarty, but if it is much more convenient and profitable to use bare php in Yii2, then you will have to close your eyes to Smarty for now.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-02-13
@gubin_niko

Whether or not to use a template engine depends on your project (it doesn't matter what framework you develop on). If you are doing a small project (for example, a business card website), which you will develop and support, then there is not much sense in using a template engine. If you are doing a larger project, and not alone, but in a team, then using a template engine, you will get a number of advantages, for example
: html which is difficult to parse.
2. It is convenient to distribute work between team members and join it together - one developer calmly does all the business logic in php, another developer (even who does not know PHP) makes presentations. For example, I have worked with a lot of people who are great at coding but don't know PHP, and developing with template engines makes it much easier to match the results of their work with the project.
3. The possibility of govnokad in the view is excluded, in the view there is only code logically related to it.

A
Anton, 2017-02-12
@karminski

Let's just say, I didn't find them (the advantages of using template engines in Yii 2). Maybe I searched badly.
EDITED :
Some would argue that templating engines are good for content managers because they don't mess with the site. However, templating engines, like native PHP, need to be learned. Which is easier - PHP or Twig? Maybe Twig, but not essential. What is more useful is definitely PHP, since you can not only upload content, but also learn how to develop sites at the same time.
In addition, I prefer to see some Compile or Fatal error on the page than to wonder why not all content is displayed on the page (as a rule, the same Twig simply ignores, does not display, erroneous content, and the error message must be looked for somewhere - then in the logs).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question