Laravel Vs Yii: The Best PHP Framework in 2020


-1
-1 points

A couple of years ago, I get a chance to work with a team of PHP developers and we had the goal to decide which  PHP framework to choose so that you could rely on it entirely and work productively in the future. We conducted a large number of studies and the sweet couple Symfony2 and Yii 1.1.14 reached the final. In the end, we stop at Yii. It seemed to us more suitable for a new project and the upcoming study of the selected framework seemed more productive. Now, over time, we are satisfied with our choice and do not regret it at all. We have briefly described Laravel Vs Yii

However, I did not stop following the development of other PHP frameworks. At the time when we made the choice, Laravel was very young and we did not take it seriously.

Now, Laravel has matured and, with the release of version 4.1, has become very attractive. In the west, more popular than Laravel, in the CIS – Yii. We decided to find out whether it is worth chasing foreign trends or not. What framework to develop sites on?

Laravel

Laravel has grown into one of the most popular PHP frameworks. In particular, due to the fact that its author Taylor Otwell created an intuitive syntax, which greatly facilitates the development process, especially for beginners.

Laravel is built on the basis of Symfony 2, which is mainly used to create very large applications by large development teams. Symfony 2 is a very solid and reliable framework, and on the other hand, quite cumbersome and redundant. Laravel could not avoid this, as it is an add-on to Symfony 2.

Despite the fact that Symfony 2 has beautifully written and detailed documentation and a slender “symphonic” architecture, it has a very high entry threshold.

I could not find sane articles or examples on the network on how to create a working user model. This pushed me from Symfony 2 towards Laravel. The latter is preferable in this regard: more books, articles and the Laracasts.com website, which will help with a quick start.

Laravel’s structure is intuitive and uses static methods to make it reusable. I think that the creator conceived Laravel as a set of wrappers for the symphony to simplify working with it.

Often, the use of a particular framework can be based on subjective preferences, since most of the frameworks are a quite powerful and flexible tool in the right hands. The choice of a tool is very important for the master and developers often think about the issue of choosing a tool.

Pros & Cons of Laravel

Laravel Benefits

  • Conveniently read Laravel collections and helpers for working with them;
  • Storage – a separate place in the structure for storage;
  • Eloquent – ORM for working with the database, implementation of the ActiveRecord template. In addition to standard CRUD operations, it has: access methods and mutators, safe deletion, request areas, relationships, model observers;
  • Artisan – allows you to manage the command line,
  • Simple routing, validation of incoming parameters;
  • Integrated SCSS and script collector (elixir);
  • Integrated Blade template engine;
  • Job queues, task scheduler;
  • Migrations and seeds;
  • PHP unit integrated unit testing system;
  • Web sockets support for creating true interactive applications;
  • ACL plugins;
  • High popularity in the west;
  • Frequent releases of new versions.

Laravel Disadvantages

  • No integrated interface templates.

Personal Opinion

“Love beautiful code? We do too”- the quote from the official site is true. Laravel is a treasure for lovers of beautiful solutions. The code is easy to read; file structure will be clear even to a beginner. By the way, there are amazing video tutorials, the basics are free. Laravel is a friendly framework. Built-in artisan-teams greatly accelerate the development process.

The key point is the proper database architecture. During development, it is advisable to cover each of the available routes with tests, fill the database with test data, adhere to the basis of Laravel’s philosophy – conciseness. To avoid clutter in controller methods, you need to use repository classes, mutators, and accelerators in models.

Laravel gives the developer great freedom in choosing solutions and how to implement them. This is both good and bad. On the one hand, the coding process is facilitated, on the other, it increases the labor costs of developing and coordinating conventions.

Yii

Now let’s talk about Yii. I want to say that compared to Symfony 2 and Laravel 4.1, Yii 1.1.14 may seem like a freak. Very powerful and in many cases much simpler, but not always logical and easy to understand.

Yes, its developers have tried and now there is a fairly active community, both English-speaking and Russian-speaking. The documentation, although translated into several languages, contains insufficient examples with source code. Laravel, at first glance, is much better in this regard.

Yii is another, more meaningful, or something. Symfony 2 and Laravel 4.1 use migrations to create tables in the database, which looks like another level of abstraction. Imagine that five programmers will jointly decide which table and with which fields to create. This is a fairly popular development approach, but not the most successful, in my opinion.

Designing a database structure should be centralized and very well thought out. It must be created before programming the code, at the planning stage of the entire project. Links, keys, indexes and more, all this should be the foundation of the project, and not be given to the will of various developers.

Even in the case when one developer is engaged in creating a project, it is better to do a database using, for example, MySql Workbench than to use migrations. Migrations do not always process the main keys correctly, which may turn into problems in the future.

There is much more to say about databases, but back to Yii. This framework includes a user-friendly web-based code generator called Gii. With it, you can easily create models based on existing tables in the database.

This allows you to first develop a structure in Workbench, and then, with the click of a button, get a model based on that structure. Yii also supports migrations, in case you prefer this way of creating tables.

The capabilities of the Gii generator are not limited to creating a model, it can also be used to create crud – a set of controllers and views that provide the ability to create, modify, view and delete data in the model (database table). That is, the application framework can be developed very quickly, which allows you to devote more time to the functionality and logic of the application.

Again, Yii 1.1.14, although quite functional, is not always elegant. Now you can object that appearance does not matter. However, a complicated structure to understand slows down the training and development, and this is always not very pleasant. Also, there are a few other unpleasant moments, the lack of composer support for dependency management and the lack of namespaces.

To the credit of the Yii developers, they, led by the creator of Qiang Xue, listened to the community and Yii 2.0 became more understandable, logical and full of new features, probably the best PHP framework that I saw.

Just imagine, you get “out of the box” frontend, backend, a working user model with authorization and a working mechanism for recovering a forgotten password. Imagine a framework that integrates with Bootstrap 3.

Although, you do not need to submit – just install the framework and create an advanced application. You will be amazed at how simple and functional it is. And yes, Yii2 uses composer to manage dependencies and to install, by the way, too!

Pros and Cons of Yii

Benefits of Yii

  • Active Form – creating forms according to the model properties.
  • Uses generally accepted architecture and methods.
  • Integrated many standard solutions for interfaces.
  • Built-in autotests of forms and security.
  • Relatively easy to learn.
  • Implemented visual generator CRUD, controllers, models (Gii).

Disadvantages of Yii

  • New versions are rare.
  • Glued front and back libraries.
  • Insufficiently flexible route formation process.
  • Rarely releases new releases.

Personal Opinion

Yii2 is a great solution for content sites with typical admin panels and a minimum of business logic. If you need to implement simple data manipulations, then do not bother with Laravel. In these cases, monolithic code will not be a problem and development on Yii2 will take less time due to a lot of ready-made solutions.

Conclusion – Which framework is better: Laravel or Yii?

When it comes to Laravel Vs Yii reliability, both Yii and Laravel development are on equal footing. The frameworks provide security at several levels (including passwords, authentication, SQL injections, cross-site fake queries, site scripts, etc.)

If you opt for one thing, then we would advise Laravel. Code Creators Inc’ specialists had to support projects on both frameworks, but with Laravel it takes less time to implement additional functionality. Similarly, with the search for bugs. In our opinion, the whole point is conciseness.


Tags:

Like it? Share with your friends!

-1
-1 points
Code Creators

Code Creators has over 13 years worth of experience playing with the SharePoint development to provide clients with excellent architecture, trending components and the right equipment to expand their online worth significantly. Our creative record with successful SharePoint online & mobile app development projects qualify us as the right fit for you.