문제

I am a CakePhp programmer. I have decided to try out the Yii framework. I would like to find out in what ways is CakePhp is similar to and different from Yii. Also, is Yii measurably faster than CakePhp as they claim?

도움이 되었습니까?

해결책 4

Diffrence between Cake and Yii

  1. Cake has model per Controller where as Yii has 1 per action i.e Controller is independent of a particular model in Yii
  2. In Yii you have to manually specify your view and models in each action
  3. In Yii related and associated records are not fetched unless specified manually
  4. In Yii a model can be of 2 types(i.e extends from) Active record model or Form model based on whether you want to save the data or not respectively
  5. Cakephp enforces convention, while yii is flexibility.

다른 팁

From personal experience, there's several difference in both frameworks, particularly the way models are handled in cake vs yii.

  • In cakephp you cannot use composite primary key, this is the main deal-breaker for me. Composite primary key is supported in Yii.
  • Cakephp enforces convention, while yii favors convention, you are not forced to follow a certain standard. While enforced convention is a good way to build good programming practice, in the end the flexibility that yii offered wins this round for me.
  • Out of the box performance, I think yii has the advantage, but as with performance tuning, with proper cache configuration, and as long as you are careful in using the ActiveRecord patterns, they are not that much apart

As a side note, I have lead web app implementation with both CakePHP and Yii, the feedback that I got from the team was that the less experienced team preferes CakePHP, while Yii is preferred by the more experienced team. Make of that what you will.

An old post but just adding some experience to it.

I have been using cake for a while now. 3 years to be precise.

Presently Yii is definitely the one leading the MVC technology in PHP. It is a framework to which may be no other PHP framework can presently compare. Personally i was really impressed with the "grid"... i thought PHP side had always lacked this in some way :) It is amazingly fast and suits wide range of developers.

For CakePHP : I have read number of blogs where people claim and probably cling on to "conventions" and "strictness" of the framework.

That said, I would agree and disagree. The claims that are usually made kind of seem pretty obvious once you get hang of it. Every rule that cake quote Forces quote can easily be overridden. Most importantly what people fail to notice is why are the conventions forced ?

If you are a developer who has lots of production pressure i would say auto-magic of cake that runs behind the scene, like getting related models data, saving related models data, defining the relations based on conventions is absolutely amazing.

The neatness that comes from following those conventions can not be explained here but only experienced.

I have also read lots of blogs where I have seen complaints over the speed of the framework. In my experience I would say, you should read the book. People define number of relationships, Cake by default fetches all its related models data. You can override this behavior and just fetch the data that you need. In fact your bind, unbind your models on the fly. Cake also has a behavior called "containable" for the very purpose.

Once you get your hands set on cake, production and developments is truly truly "RAPID".

Also, lot has changed since CakPHP 2, it's very fast and even more scalable.

All said, I really believe Cake has very poor documentation; and with better documentation, more real world examples and repositories, it would be a stronger contender.

Both frameworks are very similar, but I like Yii because is fast, uses lazy loading on models, hundred of helpers (jQuery Widgets), no need of XML/YAML, lots of extensions, console and Gii code generator, admin interface with no magic (+customizable, +control), active forum, fully and beatifully OOP Design, even system... etc.

Cakephp is a very good framework too, I like that they are planning about training courses.

I beg to differ with all of those bashing Cakephp. Being a user of both frameworks, if you know what you are doing, Cakephp is VERY flexible, meaning they request people to use conventions, but the same documentation tells you how to get around this. And so far, no real benchmarks have been provided, so shame on all of you...

In my experience, I've had to do performance tuning for Cake, not Yii so I guess I can't give the comparison as of yet of how stuff should work or how I expect stuff to work. Plus most of the benchmarks out there use Cakephp and other frameworks out of the box, so I would expect Cakephp to perform poorly.

I have worked with cakephp for about 2 years and almost completing my first in Yii. (I also did a year in ZendF and hated it) Cakephp was good for its strict system but had lots of limitations to its flexibility. Yii actually is made perfectly in a way I call "hack me". The best feature is that it starts your day with a empty Controller class which is used to inherit all your controllers. But soon I find out, I can jump in and override standard yii functions with special application wide scope, like render. In cake, you cannot do much hack in your application code. you will eventually go to core directory for some very very special cases (very bad idea when you do a core update).

The plugins/extensions in yii are so easy to create compared to cakephp.

cakephp till I know, did not support modules. I am not a module fan myself, but eventually when your app code grows, you would want to split it out into a separate group, e.g. you can outsource the module to someone else.

I believe, cakephp core is heavy enough to slowdown on high traffic sites. ZendF is much worse. Yii has a smaller call stack by the time you action is called.

There is no cakephpt.php but there is a yiit.php (entire framework in single file, production use only) for pre-compiling everything in yii using apc/etc and saving few millisecs in system file open calls.

The YII's URL ruleset and its reverse algo is unbeatable to maybe all other frameworks in php. IMO yii URL config is too easy compared to cakephp. and then, it starts to make the exact browser url too from that same config when you call createUrl, that makes your urls in your app change just with config file. if you choose to move a controller/module into a separate (sub)domain, just config changes are needed, your app code can stay careless.

The way models have attribute labels, rules, those also can be changed. all model method support get/post properties - lifesaver. then relationship rules are also much better than what is capable in cakephp. the validations and even raw php code in some rules is lot of flexibility.

The file path convention which is very flexible is also unique to yii. and then sub layouts also make it very easily to create reusability of your views.

I have tried to learn Cakephp but the documentation although extensive is poor in its structure. For example in the FormHelper section of the manual, it talks about form options without explaining how it works, just the syntax and then shows the html output. For a beginner like me, I want to know the syntax ok, but also, where does the collected form data go, how can I pick up the input fields, how can I direct form input where to go, what does it mean that you 'create the form's context', what is this context and how is this used etc.

What does this mean,

"Assuming that User hasAndBelongsToMany Group. In your controller, set a camelCase plural variable (group -> groups in this case, or ExtraFunkyModel -> extraFunkyModels) with the select options. In the controller action you would put the following:".

I did study Codeigniter and that was so intuitive in its explanations, but Cakephp documentation, while it is very nicely presented, doesn't explain things but reads more like a reference manual. I am currently looking at Yii and while its more complex than Codeigniter, the documentation is much more informative and therefore understandable than Cakephp's.

Yii is better for a beginner to MVC, but cakephp is little bit difficult for a beginner. Both are nice frameworks, but Yii have more tutorials or documentation available in net.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top