N
N
nemovalex2020-05-26 18:51:32
Yii
nemovalex, 2020-05-26 18:51:32

Is Yii2 Framework relevant in 2020?

Until recently, I used yii2, but then I had to learn and work with the Symfony 4 framework. I heard a lot of different opinions from colleagues. Some say that Yii2 is a good framework, some say that it is bad. It’s more convenient for me to use Yii2, but the words of colleagues that it’s better not to do projects on yii and that these projects are hard to maintain later haunt me. I would like to get an opinion from more experienced colleagues.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-05-27
@nemovalex

There are many nuances and it is difficult to answer unambiguously. As Ivan Shumov already wrote , a framework is a tool. Each tool is selected for a specific task:

  • CMS - content management system (Wordpress, Joomla, etc.). Created for simple and convenient site (content) management. As a rule, it is available for work to a simple user, without knowledge of programming languages. Suitable for: simple sites, blogs, where load and security are not required.
  • RAD framework (Yii2) - framework for rapid development. RAD Framework has a monolithic and cohesive architecture. It is anti-pattern and allows you to do whatever you want, as long as you quickly build your project. (The Table First pattern is used - the database was designed and the data models were generated according to the scheme). At the same time, no one tells you that it cannot be used for serious projects. For example DNS ..
  • Component frameworks (Symfony, Laravel). These are frameworks that are divided into independent components that you can connect to your project as needed. In the framework itself, only the necessary minimum is laid, and everything else is taken out into components. These components may or may not be used. Can be used for another framework (Yii2 itself uses symphony components). Doctirine, which allows you to forget about the database and focus on the code. The framework gives you some style, some structure and typing and requires better and more thoughtful coding. For example, when using twig, you won't be able to make a request to the view. What can not be said about Yii. You can build good business logic there, which is what happens ...
  • Microframeworks (Slim). In such frameworks, the very minimum is laid, and the programmer must look for everything else or write it on his own, build his application architecture. It is light and simple. Someone also refers Symfony to microframeworks. Here, many can blame me. Suitable for very simple, flexible, lightweight applications, such as microservices. The framework does not set any rules or architecture for you. You must think through all the details of the application yourself. Somewhere you use twig, somewhere Data Mapper, somewhere ActiveRecord. To work with such a framework requires a lot of knowledge and experience. Because you have to do everything yourself. Nobody thought for you here.

What to choose for?
You decide on the basis of a specific problem. There is no such thing as worse/better. To choose something, you need to try to collect a couple of projects on each. Then there will be an understanding of when and what to choose. It's like a car. Which is better BMW or LADA? Both cars, but each for its audience, according to its needs, for its tasks.
Why do others say that Yii2 is bad?
  • Version 2 is obsolete . This does not mean that the ENTIRE framework is bad, it's just that no one has been working on it for a long time. Now Yii3 is being developed, which is many times better than version 2, but version 3 is available only in demo. Therefore, if you want to write a NEW project in Yii, then I would not choose version 2. You can wait for Yii3, but no one knows when the release will be. You can start writing using Yii3-demo, but things may change by the time of release.
  • It is monolithic. If you need to make a project using many applications with different components, then you will follow the Advanced template path, where each application will be a folder: backend, forntend, console. However, under heavy load, you will need to disperse applications. Then your core will be duplicated in all applications. There will be things that you don't even need. Because Yii2 is a monolith.
  • Yii2 uses Actvie Record. AR is not bad. He is loved by many, appreciated and praised by many. But for large projects, it provides inconvenience. For example, when changing a field in the database, you have to change all the properties and hope that they have changed everywhere, since the GrigView uses magic when getting values ​​from the 'value' => 'profile.last_name'. It is also impossible to make the properties of the model (entity) private. Because of this, the state of the model can be changed anywhere and you have no control over it.
  • Lots of abstraction that the editor doesn't recognize. For example, you can call in a controller Yii::$app->user->id. You have to do a dockblock, what Useris this common/auth/Identity, notyii/web/User

Well, and so on. Each of these points can be dealt with, with the right approach. As already said, in bad hands, any code can smell. But this is the main thing. I hope others will not criticize me for controversial points. There are always disagreements in such matters) I think that I was able to convey the differences in a condensed form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question