Can you convince me to use Yii?

Now, I know its not your job to convince me, but I have my reservations and I would really like to hear the reasons why some of you made the decision to use a framework such as Yii.

It can be seen here that using Raw PHP without a framework dominates all other frameworks in terms of speed, in fact raw Php is 6 times faster than Yii. I know coding PHP in its pure form isn’t as easy, and can initially cause more bugs than using a framework, but is it really worth taking such a massive performance hit. This is likely to lead to poor user experience and increased server costs.

From what I can see, it seems far more sensible to design a clear and easy to understand file structure using includes and proper use of comments, so that you end up with clear easy to understand code but get the very best performance.

I don’t claim to be a php expert, in fact far from it, but this is how I see it based on my research so I would really like to hear your input.

James

I couldnt put this performance comparison in the first post so here it is:

http://www.sheldmandu.com/php/php-mvc-frameworks/php-mvc-framework-performance-part-1

I choose to use frameworks because of speed(sic!) and flexibility. No, not requests per second, bet development speed. Developing an internet application with framework is much faster then writing all code for every project from beginning. Also, it’s less error prone because you are using an API which can report errors, throw exceptions, etc. You can say: Hey I can reuse parts of my code! I don’t have to write everything from beginning! That’s true. But since sooner or later you will have to do project that differs from projects you have done by that time you will have to add new classes, functions, parameters to your code base. Then you will think it’s bad and it’s time to refactor that old code. Now, what about maintaining applications using your code base before refactorization? You will have most likely to support them separately. All in all not using frameworks is a one big waste of time IMHO.

You could ask if deployment time is so important why not to use CMS. Because these are usually much slower then Yii and if you want to customize them you will have to spend a lot of time to analyse given CMS’ guts. Moreover, usually CMS’ authors don’t think about developers who extended their classes and sooner or later your improvements will simply stop working. In case of frameworks, that happens only between major version change and is announced loud and clear soon enough to prepare for such a changes.

And from all these frameworks why did I pick Yii? I tried a lot of frameworks before Yii. Codeigniter, Kohana, Zend_framework, Symfony, CakePHP. I’m not in position to judge which is better or worse. I can tell you only, that after 5 minutes with Yii I knew I have found my new home. It just suites my needs, my coding style. It’s fast (for a framework), very easy to customized and contains futures I actually use. Also I’ve been using Yii since version 1.0.3 (or was that 1.0.4 ?) so I wasn’t overwhelmed by it’s size (even it’s still MUCH smaller then zend for example). I learned it as it grew and evolved. As a side note, some application I wrote for learning purpose back then are still working on newest Yii version (1.1.8 )! After 2 years and 15 version bumps I upgraded framework directory and my old code didn’t required a single code change to benefit from all bugs squashed and all improvements made since then. Of course these are a simple applications.

I will not try to convince you to use framework. Maybe you simply don’t need one. If you are developing one application and plan to upgrade and improve it for many years, then frameworkless php may be really right way to go.

Thank you for your balanced and comprehensive answer.

At the beginning, I used to think that raw php is the go, is faster I said… Then as time passed, I realized that I should keep a library of objects that will help my self to speed up the application development and also avoid code repetition… Then I started waisting my time upgrading my objects to cope with innovative methods and algorithms, with trends (social networks and so on). I even end up having my own MVC, built on top of certain libraries (RedBeanPHP, smarty templates, etc)… was just my IT ego but I surrender to Open Source. I saw that Open Source Communities do help improve the code, be up to date with trends and technology… cool and good programmers around the world, spend their free time to help others, to get better code, thus help your web application to be better.

I looked around, Zend, CI, Kohana, Symphony and no-one really convinced me… then I found Yii and never look back. Yii has a tone of great features, but the main reason was development speed, I could develop a panel in less than a week… wow! and I didn’t even know half of what I do know now. When you do work for money, development speed is the go and I don’t see my self coding with raw PHP applications as fast as I could with Yii and that means that I could take over more projects at the same time. Moreover, was my raw PHP code up to date?

Framework in general for RAD not for raw speed if you are comparing just a single php file to measure the speed than that would be comparing apple and orange kind of thing.

I also look at many framework before until I found Yii and decide Yii is the one.

In fact raw PHP isn’t faster than Yii. Maybe it is, in artifical benchmarks, but the difference disappears in a real-world application where url management, authentication/authorization, database access, templating, logging, caching, etc. has to be implemented anyway. Also, the codebase of Yii is continously tested by a fairly large community of developers and performance bottlenecks has already been detected and optimized - which is probably not true for your own code.

The article itself states that the results are essentially meaningless in the real world due to the use of a backend database and other factors in almost any project that you are going to build with a language like PHP.

That being said, that fact is you should use tools that make the programming itself easier and faster in 99% of all cases. Why? Because hardware is a lot cheaper then software, miles and miles cheaper.

Besides, most the time you can optimise any slow sections of your code, move slow DB calls into memory via caching and hire some DB guru to write some magic SQL.

At the end of the day it’s about making a good business case. Frameworks are an easy sell to management because they save a lot of money.

Do you really want to compete on speed when all you can really get out of it is a very slim margin in the real world and "six times" in a very contrived sample scenario?

If you want speed, host static HTML on a nginx server because Apache is dog slow.