Yii2 versus symfony 4 – a framework comparison

I have long worked with Yii and the symfony framework and want to try the following to explain the differences between the two frameworks from programmers point of view.

Configuration of environments

When you create Web applications is typically at least 2 Environments: The development environment, on which you want to see errors and the live environment, where this should happen. To come test environment to run automated tests and perhaps a staging environment.

Symfony raises the very skillfully, with the .env files and own folders within the configuration folder.

At Yii must the programmers themselves lend a hand, to load the correct configuration, There are only from home 3 (dev, Prod, test) Vorgsehen environments, then it is confusing.

Console of commands

Console of commands and normal controller differ in Symfony complete in terms of syntax, However, both offer same functionality.

Here has Yii the advantage of, to behave in a very similar, and to use the same syntax for controller.

Database interaction

Yii 2 relies on an own database wrapper, with the database operations and migrations are made. Databases need to about Migrations be created and it can then the entities are generated objects. Yii relies on the ActiveRecord pattern, What is unfortunately not ideal from a performance perspective in the sleep to the repository pattern of symfony, Since each entities object dragging unnecessary functionality around with you. On the other hand, everything is centrally stored in a file, be it labels or error messages for forms, Validators for individual attributes or queries on the table. The way each entity is comfortable to use a different database connection. The data can be displayed very simply using the GridView.

Symfony uses doctrine as ORM Mapper and thus has the advantage, that tables are automatically generated based on the entities definitions, and you can use a much larger range of functions, as well as more auto completition in the IDE will receive as a result of the object-oriented style of doctrine. There is no direct component to display the data in a ListView, Here you can create administration surfaces on the Sonata project back attack, can be used to create first-class backends.

Code generators

Yii has a very good code generator called GII, the in addition to the standard features such as model and extensions skeletons also CRUD interfaces and forms very nicely and quickly can be generated on the console and also with a Web frontend.

Symfony has recently Symfony maker bundle, which can be very well adapted, but not enough on the functionality of GII used.


Yii has no templating engine home, everything is permitted and is done in the view, It's full of PHP, actually an anti pattern.

Symfony has its own, very nice templating engine: Twig, with the very nice view and application logic/code can be separated.


Yii take an ausgewöhlich simple and extensive REST Implemnetierung with it, one very simple with the REST creating interfaces can including HATEOAS.

Symfony has its own FOSRest Extension, that is but not as elegant as that of Yii. HATEOAS is not available.


Both frameworks have own debugging tool bars and profiling opportunities on board.


Yii has a lot of static method calls, for now difficult to test.

Symfony uses dependency injection for all services and can be perfectly tested.

Long term support

Yii does not set up with the support, where to symfony Long term support Offer versions, It guarantees 4 Years are supported.


Yii offers home all caching features, that you may wish:

  • different cache providers: File, REDIS, Database, Memcache, Wind cache etc.
  • Database query caching
  • View fragment cache
  • HTTP cache

all very axis to use, a clear advantage for Yii.

Symfony can this be just as, only with some extra installation effort, because it is not from home doing. Symfony supports but to the ESI (Edge side includes).


Yii is very easy to set up, very much arrays with beannten keys, you have to know that and that make a hard life.

Symfony has dependency injection, What is very comfortable for the testing and work and very understandable, Produces legible and testable code.


Symfony is a professional basis for large projects to be tested. Yii is very well suited for quickly to build prototypes and smaller projects.