Yii2 Vs. Laravel Interesting Results

In March 2014, I wrote a blog about Yii2 vs. Laravel and Symfony2:

http://yii2framework.wordpress.com/tag/yii-2-0-vs-laravel/

I included a poll at the bottom of the article asking which framework people prefer and I was surprised to see that Yii2 came out on top, especially since I did not promote the blog on this forum and it was only in Alpha at the time. Also, I assumed that Laravel would fair better due to it’s over all popularity. 501 people took the poll. I know the poll is not scientifically accurate, but I thought it was very interesting, since Yii2 is only in Beta and Laravel is in production.

I keep tabs on Laravel, I think it’s a great framework, just feel that Yii2 is better for all the reasons I mention in the article and more. I also follow Laravel because I think getting a different perspective on how things can be done is useful. “Never stop Learning” is the motto from their related educational site and it’s a great motto.

[size=2]If the poll is correct in identifying a usage trend, then Yii2 is going to be bigger than Laravel. This is bound to make the Yii2 development team happy. The more I learn about Yii2, the more it affirms my earlier conclusions, which were also affirmed by this article by a programmer who compared Yii2 to Symfony2:[/size]

[size=2]

[/size]

http://www.marclewis.com/2014/05/18/yii2-vs-symfony2-first-impressions/[size=2] [/size]

[size=2]

[/size]

[size=2]Although still incomplete, I noticed a big improvement in the Yii2 guide and hope this continues. I believe the educational aspect of a framework is just as important as the framework itself. Educational support attracts programmers who will grow and learn and ultimately help nurture and extend the project. I’m really looking forward to the production release (anyone know the timeline?) and the educational materials that will follow. I think the poll results show that I’m not alone in that. Cheers and thanks again to everyone who makes it possible.[/size]

[size=2]

[/size]

[size=2]

[/size]

Guide is in the works. Current state is very drafty. Also I’m going to put together a cookbook. Once we solve these issues we’ll release RC. Release date depends on feedback we’ll get and issues reported.

Thanks for your reply. Just so you know, your 1st cookbook was well-liked at my company and we purchased several copies for the work our programmers are doing in Yii 1.14, we were such dinosaurs in the beginning of the project, we actually bought printed copies[size=2] . Looking forward to your next commercial book, if you are going to do one in addition to the online version mentioned above. Ideally, someone will write a book that steps through building an advanced application that at the same time teaches the advanced oop and Yii concepts. As someone who is still personally just learning, I feel the current drafty docs are moving in the right direction and very helpful.[/size]

I hope you are getting the feedback you need to push this along. I think the poll shows that interest in Yii2 is high, considering it’s from a single blog entry that wasn’t promoted at all.

People are beginning to notice that Laravel has great marketing but is dog slow. Laravel incorporates a ton of Symfony stuff, and as the Techempower PHP Framework Benchmarks show, the performance of both Symfony and Laravel rank near the bottom.[b]

Laravel 4 is even slower than CakePHP[/b]:

Laravel 4 is also morbidly obese, it takes up a bloated 92 MB in disk in its normal composer install:


du -sh  92 MB

-------------------------------------------------------------------------------

Language                     files          blank        comment           code

-------------------------------------------------------------------------------

PHP                           2983          53301         116722         209478

XML                            106            392            114          19997

Javascript                       9            681           1041           3411

XSD                              3             63             28           2505

HTML                            37             17              0           1211

CSS                              7            127              9            987

XSLT                             4             92              3            807

Bourne Shell                    10             14             10            294

YAML                            21             24              0            135

DOS Batch                        1             16              1             96

Python                           2             68            147             74

Smarty                           1              0              0             73

make                             1             15              4             70

-------------------------------------------------------------------------------

SUM:                          3185          54810         118079         239138

-------------------------------------------------------------------------------

Laravel is also a memory hog, and L4 consumes twice the memory as the previous version, and it is twice slower even after otpimization. Here are some performance results posted in the Laravel Forums:

Laravel 4


Requests per second:    21.35 [#/sec] (mean)

Time per request:       468.311 [ms] (mean)

Time per request:       46.831 [ms] (mean, across all concurrent requests)

Transfer rate:          10.96 [Kbytes/sec] received

Yii 1.1.13


Requests per second:    277.74 [#/sec] (mean)

Time per request:       36.004 [ms] (mean)

Time per request:       3.600 [ms] (mean, across all concurrent requests)

Transfer rate:          63.47 [Kbytes/sec] received

CakePHP 2.3.5


Requests per second:    129.45 [#/sec] (mean)

Time per request:       77.252 [ms] (mean)

Time per request:       7.725 [ms] (mean, across all concurrent requests)

Transfer rate:          29.20 [Kbytes/sec] received

As the Laravel user that produced the above tests put it, "I fell in love with L4, but it seems its performance is not ready for production."

That was when L4 was just released. I could be wrong but there’s a high chance that it was somehow fixed and performance isn’t that bad.

The Techempower Benchmarks, are kept up to date (last round was done May 2014) and Laravel is still at the bottom of the performance table along with Symfony 2. CakePHP is faster than both.

BTW, it would be nice to add Yii to those benchmarks and see how it compares.

Yii 2.0 seems to be there already: https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/PHP/php-yii2

Quite old version though. Would be great to update it.

If Yii has been added to Techempower’s Github, why is it not listed among the benchmarked frameworks?

Because you need to wait for next round.

Over at the Laravel forums they are already finding that Yii2 is significantly faster than Laravel 4.x, more than twice the speed:

I can’t wait to see more Yii2 performance comparisons.

It’s not just speed that makes Yii 2 worth using, but I’ll save the deeper comparison for my blog. I was very shocked by the results of the poll. First, I didn’t promote the poll here, so the results were not skewed, and the percentage spread between Yii 2 60% vs. Laravel 35% has not changed over time. Over 700 people have taken the poll to date, and I think that’s a good sample of how people feel about it. And as someone who really took the time to research the major PHP frameworks before settling on one to use, it makes me feel confident in my choice. Of course the best way to know is to just try it yourself. 6 months after starting, I can say that I love using Yii 2.

If you google yii2 you get less results than if you google laravel (300k’ish vs 1.6m), which means that someone has higher chance of finding your blog if they are searching for information about yii2 than if they are searching for information about laravel.

In other words, people who manage to find your blog are (probably) mostly yii developpers, which could explain the result you are getting.

Perhaps you could confirm this with google analytics by looking at what your user search for in search engine to find your blog.

While there are indeed many Laravel users in US and europe Yii 2.0 seems to be getting more europe attention nowadays: http://phpmagazin.de/artikel/php-framework-umfrage-2014-176990

Most of the traffic comes from Google. Wordpress has good analytics and it tells me most of the traffic comes from Google. Not sure I agree with your conclusion, Yii 2 is only half the search string, Laravel is the other half. Analytics would give me more data, but at this point, I don’t have time for that. Well, anyway, a web poll is not considered scientific, so I don’t want to try to turn it into a science or give it more weight than it is due. I just found the results interesting and very unexpected.

Laravel moved through the PHP community with lightning speed, marketed extremely well in the way it was done. Thre’s nothing wrong with their framework, and it’s a remarkable achievement for their sole developer. I think he really followed the ideas in Robert Martin’s Clean Code to the letter and we can see how that played out in terms of his being able to create a popular framework. Laravel is very syntatically pleasing. Their idea is to make the framework as simple and as accessible as possible. It worked, but there are short-comings, in my opinion, mostly derived from Symfony and Doctrine. I will save that deeper comparison for my blog, it would be too long here.

One thing I will say, though, is I think there was mabye too much emphasis on style with them. For example, as someone who read their books, watched their videos, I can’t count the number of times I heard the phrase “dependency injection,” but it was a lot. So while that was interesting, and I’m sure fascinating for programmers on a certain level, I was far more interested in building an actual application. The more they taught me about DI, the less I knew about form validation or how to setup the user login, authorzation, etc., in other words, how to make a viable application.

I’m perfectly wililng to admit the shortcoming is probably with me. However I also talked to a number of advanced programmers who were far above my level and to my surprise, none of them used Laravel. And when I asked at my own company if we should switch from Yii to Laravel, on a project with over 300 tables in the DB, the answer was a very definite no, more like a “Are you kidding me?”

Now that I’m a little further along in my skill level, I can see there is plenty of DI in Yii 2, along with beautiful syntax and elegant architecture. But more importantly, it just helps me build an application.

Whenever you voice an opinion of preference of framework, you risk alienating a group of people you might have to work with some day. At the same time, I think there is such a thing as truth in programming. Some ways of doing things are better than other ways of doing things. As long as we’re honest about where the opinion is coming from and respectful of the hard work of others, I don’t see why we shouldn’t express it.

@Samdark, to your point, the wordpress stats show the traffic comes in from all over the world, the poll is not skewed by the US.

Well I wasn’t trying to conclude anything. I was trying to find an explanation.

I remember voting on that poll (for yii2) a few months ago. I searched for "Yii vs" and your blog was in the first page of results. Searching "Laravel vs" puts it at the end of the second page of results.

I was under the impression that laravel was a lot more popular, due to it’s big focus on marketing. “The PHP Framework For Web Artisans” (lol). I keep seeing blogs about how awesome laravel is, tutorials etc.

I read the laravel doc, downloaded laravel and messed around with it to see what all the fuss was about but in the end I didn’t see a good reason to switch from Yii2 to laravel.

I’m glad to see the result posted by samdark. Seems like Yii is getting the attention it deserves.

Laravel’s popularity is the result of its all-consuming focus on marketing but also lucky timing: it came when the most popular frameworks on both the low (CodeIgniter) and high end (Yii) failed to answer the call to modernize (as both EllisLabs and the Yii team kept a glacial development pace) so Laravel quickly filled the pent-up demand for something “cool and exciting” and has grown to occupy the middle of the coding skill spectrum, like a hinge between CI and Yii.

While CodeIgniter will have a hard time fighting back to reclaim the lost ground (new owner BCIT seems shockingly old fashioned and un-cool), Yii2 is poised to dominate the medium-high skill framework segment, taking from both Laravel and Symfony, as shown in PHPMagazin.de survey pointed out by Samdark.

Quoting from the German website:

"Some time ago we called you to participate in the great PHPmagazin.de framework survey, we wanted to know what your preferred PHP framework is for a new project. In our survey 32 frameworks were available and a total of 5,138 votes were cast. The results were dominated by big players like Symfony, Zend Framework or Laravel, but one framework rose above the others…

The winner with an amazing 28 percent: The Yii Framework!"

“Yii’s top position arrived, at least for us, as quite a surprise, especially for such a clear win. In our last survey in 2012 the Yii framework tied with CakePHP for fourth place. Version 2.0 of the Yii framework was released a few weeks ago and it scored especially high with a simple installation, the use of modern technologies and high safety standards. Despite delaying the new release again and again, Yii kept its high reputation in the community, and under the hood a lot has happened.”

Sorry men, my English is not my natural language (hopefully :lol: )

It shows clearly that SamDark is kind enough to do not just promote its framework. And that he is honest.

I use Laravel 4 and Laravel 5 even if this last version is not stable enough to production.

And I use Yii1 for years, when i decided to switch to Laravel.

Comparing Laravel and Yii by the way of efficiency is a kind of "baby work".

They are so much others points to consider;

For most of your projects Laravel performances are far enough.

But looking at Code readability, Maintainance, reusability, scalability etc which sound better on a industrial approach.

Laravel is a very great framework, it is very flexible. Too much to my point of view. You have mayny ways to accomplish the same thing.

It is one of the strengh of Laravel but also is disavantage (for some of us), towards industrial point of view (Working with 4 or 5 teammates becomes complicate when you have not the same coding culture.

Laravel is built upon the idea of puzzling. It will become a ‘light base’ (Laravel 5 is smaller than Laravel 4) for playing with community production, instead of having a monolithic framework. It becomes an agnostic framework base for everything coming from packagist.

The idea is great, the base idea of the Web is behind that (contributing again and again).

But, but, but.

I come back to Yii2. (even if the documentation is … poor)

And mainly because Yii2 promote (even if you can bypass them) rules. With Yii there is a natural and promoted way of doing a task. And that’s great to go to reuse and stable base of work in team.

Laravel is quite confusing because it lacks this (could be a chance for very small projects, but not for large)

I come back also because the community, Yii leads a far more structured and leveraged (from beginners to expert) community than Laravel.

Also the way of thinking some parts of design is … cooler.

So i come back to Yii2, even if i paine to go throughout doc

That’s my point of view.

ajaxian

Any particular issues with the docs? We definitely want to improve it.

@SamDark

Regarding Helpers the 3 or 4 last topics are under construction

Concerning the advanced app, I would appreciate more precision about Fixtures. I’m quite lost about that and also concerning i18n.

For Fixtures for instances, I’m stuck since 1 hour on ‘Error: The template path “@tests/unit/templates/fixtures” does not exist’

Where to define this alias ? Do i miss something in the doc ? … don’t know

In the doc there is a link which is intended to route them on github doc but leads to 404. (https://github.com/yiisoft/yii2/blob/master/docs/guide/test-fixture.md)

I tried to set alias test in common (where I put my common fixtures), but . pfff always same thing)

To sum up it lacks about configuration hints/doc on advanced app. For i18n i’m lost about where to put stuff, i.e. where to put common translation languages directory (in commmon, or in root web site), I have 3 languages directories, one for common, one for backend and last one for frontend. Conf is not so obvious. For instance I don’t know how to set the target language


return [

    'id' => 'applicationID',

    'basePath' => dirname(__DIR__),

    // ...

    'language' => 'ru-RU', // <- here!

    // ...

]

Perfect ! but where exactly. in @common/config/main or main-local.php ? in config.php ?

Thing i would appreciate is a more dedicated sections on advanced App (on each topics: tests, internationalization, etc)

In addition, it would be great to have a kind of cookbook like the one in Yii1 (Blog)