TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana vs Yii
  • The company I'm currently working for uses Yii framework for a year now. As a Kohana evangelist I felt obligated to at least have the PHP team (quite a few developers) look at it so we can get to using Kohana in the future. My problem is I don't really have enough experience with Yii to compare it directly to Kohana and the next friday is my deadline for the "Kohana vs. Yii" presentation.

    I need everyone who used Yii here to give me info on exact topics you'd point out as advantages / flaws. Mine current arguments are:

    • Strict development - Kohana being really strict about it's additions / conventions
    • Unit tests - Kohana being completely unit tested
    • Userguide - ability to have the whole framework and application (with API) documented 'automatically'
    • Actual OOP
    • No pattern abuse / misuse (e.g. having the Event / Behaviour patterns in Yii opposed to Kohana where nothing 'hacky' like that is used)
    • No convention abuse - Yii has quite a few convention flaws, e.g. using eval() "natively"
    • Actual hierarchy - Kohana has class naming / file system placement conventions strictly defined opposed to Yii where ... classes can be all over the place
    • Modularity - the ease of adding modules and overriding / extending framework's classes inside of them
    • HMVC - being "what PHP always missed", having a useful pattern like this and respecting the RFC 2616
    • Know what the framework is doing by reading it's clean, well documented code (opposed to Yii where the coding convention itself isn't readable, not to mention having the whole method commented before it's definition only)
    • You want to program and not write arrays

    I'll add new things here

    I need you to provide me with as many examples as possible. This is a really great development team I'm talking about so I'd love if they could actually "start looking" :)

    I'll make a slideshow and put it on slideshare for all future references.

  • Transparent extensibility would have to be a big plus mark in the kohana column for a dev team, i think - so extra functionality cascades throughout modules & system without needing to edit any of those files.

  • Unit tests - Kohana being completely unit tested aover yii where ActiveRecord returns unexpected values, etc.

    We've got a fair amount of test coverage for core (60% or so) but ORM doesn't have any coverage

  • Maybe you should ask this in Yii's forum too. If you do it please complete this list for us too.
    I love "vs" :)
    I think they are an easy and fast way to learn.

  • Asking on the specific software's forums are sure to get a biased opinion, however.

  • That's gotta suck if you want to use one framework, but are forced to use another one. I sometimes feel like that when maintaining a ko2 app, whishing it was ko3. Thankfully ko2 is nice, dunno about yii though.

  • Here's an old thread comparing 2.3 and Yii that might be of interest:

    http://www.yiiframework.com/forum/index.php?/topic/5576-yii-11-vs-10-versus-kohana-23/

    I must say, I do like the new look for the Yii site - user comments on each fast-loading API page are nice, too. I see on the roadmap that Yii will be completely re-written for PHP 5.3. ;-)

  • @zeebee I included the modularity bullet, though I don't see many true facts in that old topic.

    @BRMatt are the orm unit tests going to be written soon?

    @enridp I have asked but no one seems to care there anyways

    @zombor my primary goal is to get opinions of ex Yii devs who've chosen Kohana over Yii, though I was objective enough to post the topic on their forums as well

    @goyote it especially sucks when you have to work on Yii projects with no actual conventions defined; Yii's coding style & conventions are extremely ugly so every developer seems to do it his own way, opposed to Kohana where coding style simply cannot be more beautiful with PHP (including conventions like "where should this be?").

  • orm unit tests will probably be coming in 3.3

  • Yii does indeed have a quite peculiar coding style, particularly with respect to spaces & braces, so we end up with:

    public function runController($route)
    {
        if(($ca=$this->createController($route))!==null)
        {
            list($controller,$actionID)=$ca;
            $oldController=$this->_controller;
            $this->_controller=$controller;
            $controller->init();
            $controller->run($actionID);
            $this->_controller=$oldController;
        }
        else
            throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',
                array('{route}'=>$route===''?$this->defaultController:$route)));
    }
    

    I couldn't cope with all that myself, but I do understand why it has a large and growing community - all the OOB, scaffolding and web-based code generator sauce must be quite seductive.

  • all the OOB, scaffolding and web-based code generator sauce must be quite seductive.

    And it's the polar opposite of kohana :)

  • Here's another example that made my eyes bleed:

    public static function getPathOfAlias($alias)
    {
        if(isset(self::$_aliases[$alias]))
            return self::$_aliases[$alias];
        else if(($pos=strpos($alias,'.'))!==false)
        {
            $rootAlias=substr($alias,0,$pos);
            if(isset(self::$_aliases[$rootAlias]))
                return self::$_aliases[$alias]=rtrim(self::$_aliases[$rootAlias].DIRECTORY_SEPARATOR.str_replace('.',DIRECTORY_SEPARATOR,substr($alias,$pos+1)),'*'.DIRECTORY_SEPARATOR);
            else if(self::$_app instanceof CWebApplication)
            {
                if(self::$_app->findModule($rootAlias)!==null)
                    return self::getPathOfAlias($alias);
            }
        }
        return false;
    }
    

    Oh, how I count our Kohana blessings, I think I'm almost cured of my addiction to the PEAR standards now, too. Just need to get used to AND and OR ....

  • Coming from a Java background, Yii looks very much like a fake-OO PHP framework I did back in 2000 where all the code looks like Java (lowerCamelCase methods and UpperCamelCase class names) and it certainly does NOT match any PHP functions (lower case with underscores) so own code looks really messy with all the different styles mixed in. But since I didn't want to change, I was determined to use Yii because it looked like what I already know.

    After using Yii for 2 days, it just felt heavy and from @zeebee's code snippet above, YES -- if you need to look at something inside Yii, your eyes will bleed. So, I had to unlearn all my java coding and naming conventions and accept the Kohana way (believe me, I did not want to) and 2 years later still is the right decision.

  • I tried Yii for a week and threw it out before I blew my brains out. It's got a couple cool things, but it's naming conventions are too damn weird for me.

  • @chrisgo There's lots of camelCase in native PHP classes, though, starting with our favourites Exception, Reflection, ArrayObject, etc., and you're stuck with mixing styles if you want to implement any of the SPL interfaces, or make use of any PEAR classes, and really the majority of libraries out there. Kohana does a pretty good job of wrapping these, but it's unique coding style is probably just as limiting in terms of sharing beyond the closed circle of the framework as Yii in its own way.

    But I suspect I'm drifting off-topic ....

  • I think Kohana wraps a lot of it fairly well like you said ...

  • Three things made me leave Yii for Kohana:

    • The strictly organized coding style that Kohana enforces (allthough you can probably make a mess of it if you wanted to) Which comes in handy when you're on a team: some solid ground rules are set.
    • Yii does a lot of magic, and looking under the hood to unravel it can be painful. In Kohana it's much easier to understand what's going on.
    • HMVC. Not having to put common tasks in widgets, but just use the same controller / action setup for everything

    Some things that made me doubt my decision (which your Yii-evangelists are bound to bring up)

    • Docs + Tutorials: When just starting out Kohana can be a bit rough. Especially if you don't want to look at the code.
    • Compatibility/long term support: With the rise of so many frameworks, will Kohana still be around in five years, or will everybody have converted to Symfony or Zend (The same concern goes for Yii)
    • Naming conventions / filesystem. There's allways a risk of somebody writing a class in a module that has the same name as the one you're working on.
  • Concerning your last point, that a module could have the same class name as a class in the application, I think this is a reason why we should have strict guidelines when creating modules.

  • Me too @xenakis, or at least some kind of module analysis to ensure no conflicts. Edit: However as pointed out by @zombor previously, modules are designed to simply allow an extension of the cascading file system and not provide more functionality than that.

  • @DrPheltRight exactly, there is no sense in extending core classes in modules as long as Kohana is < 5.3 :)

  • Yii VS. Kohana?

    With Yii will you have the opportunity to be flogged in the forums by Zombor? I don't think so.

  • Is that meant to be positive or negative? ;-)

  • lol (?)

  • Positive, of course.

  • It's way better than Qiang's previous endeavor (Prado). You had to have a very specific mindset to use that (and an uncanny love for ASP-style tags). From what I can tell by only using it briefly, Yii is wicked fast with APC.... they advertise it as such, but really anything is wicked fast if it utilizes APC. The problem I have with Yii is it's still Qiang's brainchild, and that guy's brain just works differently sometimes than the rest of the user base, and his methods sometimes required lot extra effort to understand (this was especially apparent in Prado when it came to things like variable scope, page states, and Ajax). The big problem came when a developer tried implementing something from the docs in a practical application (most of the examples were simple paradigms), and I'd see a torrent of forum postings titled "Why doesn't this work: ___________?", to which Qiang or (other Prado experts finely attuned to the nuances of the framework) would respond: "It's simple: [insert instructions analogous to driving a car backwards in outer space]."

    It seems that this has improved with Yii--though the problems are still more or less around, just far better than Prado. At the very least it seems like they addressed the system problems with Prado: templating, inconsistencies involving scope and page state, and a very horrible language barrier in the community--thousands of posts splintered across multiple language forums. It was always frustrating to search for a solution to a problem, only to find one forum post written in Polish slang that gives Google Translate a run for its money.

    As @mtn brought up in one of his bullet points, it's definitely hard to grok the stuff "under the hood." That's my biggest hang-up with Yii, and one of the biggest advantages I see for Kohana. Kohana is lightweight, and easier to sift through and understand, as well as amend or alter. Yii, on the other hand, while highly modular, is very dense and thus can really take away from the DRY experience if your goals don't run within Yii's guidelines. It's not a difference that I'd yell at them for--it just means it's a little more specialized. I could probably think of a few quick-and-easy projects I wouldn't mind using Yii for if they fit the right parameters. But, I'm definitely still a fan of Kohana because it's lightweight both in footprint as well as actual weight in code. :)

  • I ended up not comparing Kohana to Yii but talking about features that make Kohana as good as it gets. Posted the presentation slides on slideshare:

    http://www.slideshare.net/delalic/kohana-31

  • Nice work @Kemo

  • Good presentation @Kemo. Where did you get the image for slide 29? It looks like it would be good to put in the guide in a page discussing HMVC. (I don't even see a page right now that is discussing HMVC...)

  • Thanks @Kemo for sharing the slides, it was nice to read it

  • nice slides Kemo!

  • Hello, some time ago I did a benchmark between frameworks. The source document of a presentation I made to implement the "Kohana" in the the company where I work . The comparison was made ​​between the "Cake", "CodeIgniter", "Yii", "Kohana"and "W3Haus Framework" (the version developed in-house). The result was taken atravez a hello world application without connections to the bank. Sorry for not translating the document. The result was as follows:

    http://bit.ly/jgarXP

    The titles indicate: Requests per second Average length of connection Average delivery time

  • So this is only a hello world application, or was it more complicated? I always thought Yii was faster in those kind of 'simple' benchmarks... Nice to see the opposite! :)

  • @willemmulder After testing I found that Yii is fast only in the implementation of the demonstration site. If mounted in the way the application. Only reach an acceptable performace.

  • IIRC, Yii's benchmarks are with complete caching on, including output caching. They aren't that fast in real life.

  • Good to know! I was having a little discussion with a friend of mine, and he has concluded to stick with Kohana anyways, but this then is defeating the most important argument for Yii: that it is fast. Thanks!

  • @chrisgo PHP is a pretty terrible basis for naming conventions, it is utterly confused, sometimes it splits words with underscores - str_shuffle, but then sometimes it doesn't - strtolower... Same goes for the order of args, sometimes it will put the needle first - str_replace, other times it puts the haystack first - stristr, matching PHP is absolutely the last thing people should consider when deciding upon coding conventions.

  • Yii is one of the best Web2.0 framework ,i like it most and i am sure in the recent year it gona get huge

    Thanks Kind Regards

  • Don't post advertisements here.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion