Yii vs Symfony: A Battle of the PHP Frameworks

In the ongoing battle between PHP frameworks I’ve found two that seem to be widely adopted and simple to use. The concept of a framework is to eliminate the spaghetti code that we developers get ourselves into. Very complex projects can become a nightmare to manage and to document many times if we decide to go at it ourselves. Granted, we can come up with some ingenious solutions, but when it is all said and done we’ve created something that is unique and may or may not be easily replicated or maintained. Enter the framework. Frameworks can do all sorts functions out of the box. Some are built are certain programming ideas and others just provide simplified coding methods. The two that I’ve chosen to highlight are both MVC (Model-View-Controller) implementations and open-source.

Yii is honestly my favorite, but I will not try to make my comparison biased because of it. What I like about it the most is the simplicity of the application. With a single command-line command you have an initial project ready to go. Adding controllers, views, and models is a breeze because you don’t have to provide the routing patterns as Yii will handle it for you. Likewise, creating forms, controllers, and models are just as easy if you use the gii tool provided with the framework. Other features such as templating are quite easy to use as well. Also, Yii makes use of lazy loading, this is not a bad thing although it might sound like it. Yii only loads classes when needed rather than loading all classes needed at the initial run. This cuts down on run time and memory usage while increasing speed, which I think we all can agree is a good thing. Others who come from the Microsoft world will notice the file structure and other similarities to the .NET framework, which makes it very enticing for many.

Yii has excellent documentation and forums to dive into if you have any problems or are looking for answers. It is a new comer in the framework world and one may not find all the answers up front. Symphony has a larger fan base and will likely be suitable for those who are just starting out. My suggestion here is that if you like to play by the rules and are an experience OOP developer go with Yii. If you are just starting out it may be easier to go with Symphony.

Symphony is very similar to Yii and actually predates it as a framework. What Symphony lacks in ease of use it makes up for in options and flexibility. When adding controllers you must setup the routing information for each and this can be a drag. On the other hand, if you’re looking to create a very one of the kind implementation this is very useful as you can manipulate the framework to do what you like. One crucial downfall is that the latest Symphony 2.0 is not backwards compatible with 1.0 because of the switch from PHP 4 to 5. This will likely be a tripping point for many legacy systems already using Symphony.

The battle still exists for which framework is the fastest and my answer is you can never exactly tell. With caching enabled both frameworks move extremely fast, but this is also a very subjective matter. Depending on how you’re code is written is ultimately the indicator of speed. There are several sites which will show you a comparison of the frameworks running a hello world application with varying levels of setups. My suggestion is if it means that much to you then run your own tests and make the decision for yourself.

All in all they are very similar and both have their ups and downs. Myself I like the quickness and rapid development that the Yii framework allows for. I can in under 5 minutes have a small website up and running with no problems. Yii provides the purest MVC architecture possible and for that I like it the most.

Related Post

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.