fb
Back

Frameworks: from Yii2 to Laravel. Interview with a back-end developer

Frameworks: from Yii2 to Laravel. Interview with a back-end developer

– Oleksandr, why was it decided to move from Yii2 to Laravel? What is the difference between them?

To compare frameworks is a pretty holy war topic, the result of which is that each of them has its advantages. I worked with both, so I will try to clarify my approach to choosing a framework.

I immediately warn why we do not consider Symfony.

Symfony is a lower-level framework which is more commonly used as a basis for large projects. For example: writing your own framework for development. It is, in principle, not comparable to Laravel and Yii2 because they use its components in their implementations.

Symfony is a powerful product that allows you to flexibly customize virtually any system you need. But there is little what can be used as ready-made solutions for small-scale typical tasks. On GitHub you can find many libraries or extensions written for the same Yii2 or Laravel just in Symfony.

Yii2

Let’s start with Yii2, as this is my first framework which I’ve learned. By the way, learning this framework is very easy, with minimal knowledge of OOP (object-oriented programming).

The benefits of Yii2 

  • Easy to learn, low start development
  • Has many built-in solutions for interfaces
  • Excellent Generator of Models, Controllers CRUD

The disadvantages of Yii2

  • The solidity of the framework
  • Poorly developing (new releases)
  • Too “pasted” libraries for frontend and backend.

– And what about each of the points?

  • Easy to learn. This is true. After couple days sitting on a small project, you can begin to quietly code on it. Most recently, they updated their site with guides and documentation.
  • Built-in interface solutions can be described for a long time, but I’ll try briefly. Bootstrap is built into the system, unfortunately for the third time, and a bunch of custom modules that are associated with it.

You can even have a bad Bootstrap layout, and with the help of built-in methods in Yii2 make pop-up modal dialogs, drop-down lists, spoilers, etc.

  • Generator models, controllers – a separate moment, but partly related to the previous one. In Yii2, there is some kind of GUI area to choose from for different generations. Note that other frames, if there are generators, are usually console only. There is also an interface and very convenient to use, called this beauty – gii.

The models are not generated as in Laravel. The interface specifies the table, name and location of the class for the model, taking into account the namespace, the program itself tightens all dependencies (can be disabled if not required), if foreign key is placed, and “rolls out” the model, with all the properties taken by the columns of the table and methods for communicating with others.

CRUD generates prefabricated interfaces, controllers to them, to control the data in the specified model. That is, you first need to create a model and then do the CRUD generation. On the way out, you will get a ready-made interface with a specific address where you can make new spreadsheet entries, edit and delete them.

Very convenient to use to create admin panels or dashboards. A ready-made interface is quickly generated, which can then be edited and used by assigning router protection by authorization, or otherwise. The interface uses many built-in widgets that you can customize too.

This is really fast development of systems with data management interfaces. You can quickly create a separate CMS for the needs of a particular project. As for me, this is a major plus of Yii2 compared to other frameworks.

Now – about the disadvantages.

  • The framework is monolithic. All development in modern realities is to combat it. High “connectivity” of parts of the framework, which makes it difficult to use third-party components.

Inconsistency with solid principles, great mixing of areas of responsibility. Widespread use of the service locator. The framework is perfect for rapid prototyping, something more serious about writing it is very painful.

  • It is slowly developing – decisions in the community are made very slowly.

It should be noted that Yii2 still uses Bootstrap-3, and quite a lot of new ones have been added to it recently.

  • Well, the last point is the “glued together” of the frontend with the backend. Many widgets, etc., immediately generate ready-made solutions in views. It’s good and fast. But many of them throw scripts right into the body of the page, in the code of these widgets mixed php and html, which does not look good. Maintaining such code is quite problematic.

This method of development does not allow the use of collectors, such as WebPack, Gulp or other. That is, you can use … But you have to give up the main advantage of Yii2 – not to use generators and ready solutions for the interface. Do not apply classes that allow you to compile scripts and css into assets and the like. And if you give them up, what will be left?..

In modern design, everything goes as far as possible to separate the frontend from the backend, and in this respect Yii2 is outdated.

– And what about Laravel?

Yep, since we got to know Yii2 in some detail, let’s compare it to Laravel.

The benefits of Laravel

  • Component architecture
  • Has a built-in script builder and scss
  • Built-in Blade Template
  • Flexible routing
  • Flexible REST API writing capabilities
  • Fast-paced

The disadvantages of Laravel

  • Great functionality works through the facades
  • It is studied a little harder Yii2
  • There is no official documentation in Russian
  • No built-in interface generators
  • Higher entry threshold

Component architecture allows you to design the system very flexibly. The ability to easily use third-party packages. Following solid principles, frequent updates and adherence / implementation of new psr standards. The framework is blamed for its facades, but in essence it allows them not to use. All architecture is in your hands.

The built-in builder is WebPack based, in fact it’s an add-on above it. It makes it easy to get started and build a frontend without digging into the big WebPack manuals and its settings.

It’s called laravel mix on the system, and it’s essentially WebPack, already tuned to most tasks, where we just specify where we get the weekend and where we put the result.

Mix’ example

The example is the standard configuration that you see immediately after you install the framework. There are many mixes you can create there if you have a division of several frontend applications.

The mix is ​​able to compile scss, single-file Vue components at once, as well as in new versions of Laravel, Vue.js goes straight away in delivering the framework.

So, for 2019, the Yii2 framework is outdated. And that is objective. Most of the new projects on it are no longer started. By studying Yii2 in 2019, you doom yourself to support relatively new projects with poor quality code. What will happen to Yii3 is hard to say.

Therefore, it was decided to move towards new technologies. Weigh the pros and cons, the transition time. At Web-Systems Solutions, we have chosen Laravel – with its huge eco-system that is being developed.

– What difficulties did you encounter during the transition?

There were no major difficulties, as there is a lot of materials to study + good documentation and guides on the official site. And not only. The main desire – and it will work!

– What tips can you give to those who make the transition? And what will it bring?

Do not doubt the decision chosen, do not stop halfway. As a result, you get up-to-date technology that is enjoyable to use and develop with it.

– What do you think is the most interesting part of a back-end developer’s work?

Constant movement and learning of new technologies. Designing the architecture of the web application, implementing new approaches. The backend is closely related to the field of devops – so you have to constantly expand your outlook and outlook. Constant search for better solutions. A lot of non-standard tasks that make you think well.

Let's start project together!

To lead the eCommerce market, you need ambition and possibilities to grow. We assist our clients in achieving real business results.

Let's get started