Laravel Vs Yii: 8 Facts You Should Know Today

If you have a knack of building web apps for your business in PHP, Laravel and Yii are familiar names to you. In fact, you must have heard about the recent hype about Laravel too. Laravel indeed is a great framework and considered to be the best now-a-days. In our previous blog, we have also supported this fact and still believe in it. However, when our PHP team at ValueCoders was trying to move to Laravel from Yii2, they came across a few facts which can’t be overlooked. This brings us the topic Laravel vs Yii : 8 facts to know today!

We believe that the main idea behind using any tool or a framework is to get your task done in the best possible way. We are using Yii & Yii2 for about 3 years and started working in Laravel since the last year. Yii2 experience was good, but before starting to work on Laravel, we got the feeling that it would be far more smarter framework than Yii.

Also Read: Symfony Vs Laravel: which PHP framework to choose?

However, here is our experience. We found the following 8 differences while researching on Laravel vs Yii –

1) VALIDATION Laravel vs Yii

Laravel :: No scenario based validation is available in default package of Laravel. It does not provide any construct to validate a model at different scenarios. Moreover, there is no way to define fillable attributes based on scenario. You will have to custom code everything.

Yii :: Both massive assignment of model from the request parameters and its validation can be done based on scenario. Here is an example of Data type validation in Yii2

Laravel vs Yii

 2) CLIENT SIDE VALIDATION Laravel vs Yii

Laravel :: No default support is available on Laravel.

Yii :: Provides out of box client side (JavaScript) validation of the form. You need to define only one set of rules of the model for validation in server side and client side.


Home page


3) ROUTING Yii vs Laravel

Laravel :: We are suppose to declare route to each and every action in all controllers. We find its quite odd !! Besides why protected function of controller is being accessed from outside if provided in route. Somehow we believe that it should be task of framework to provide default routing. Even CodeIgniter provides it !! Though we thank Laravel for providing Resource Routing.

Yii :: Simple routing is possible as we don’t need mention route to each and every action. Route of actions are pickup by default. This same is the case of CodeIgniter as well.

Read More: Laravel Spark 6.0 is Now Available


4) CRUD GENERATION Laravel vs Yii2

Laravel :: No default support. Many projects have admin panel for CRUD functionality from various tables.

Yii::  Yii2 includes a handy tool, named Gii, that provides rapid prototyping by generating commonly used code snippets as well as complete CRUD controllers.

Gii provides a Web-based interface for you to interactively generate the code you want. It also provides a command line interface for people who prefer to work with their console windows most of the time.

Gii, Laravel vs Yii


 5) DOCUMENTATION Yii vs Laravel

Laravel :: Laravel has the best documentation for sure.  However, we personally believe the documentation could have been organized better and written in a more generic way as when you create a big thing, you increase the chances of making loopholes.

Yii:: On the other hand, though Yii does not have a very strong documentation like Laravel still it’s pretty organized. Moreover, it does not has a steep learning curve. If you are only following the docs you can easily start with basic coding.


 6) THE PROMISE

Laravel :: “The PHP Framework For Web Artisans”, even after working for one year, we are still trying to get the feel of an “Artisian”. Frankly, we choose to work in Laravel because of such “razzmatazz”.

Yii:: Yii on the other hand has a pretty simple outlook where you can call the database from one model AND write code easily without creating many files.

Also Read: Can We Build Enterprise Apps With Laravel?


 7) RESOURCES AND SUPPORT: Laravel vs Yii2

Laravel:: Laravel has a large community with good support and it’s growing everyday. However, it is a new framework(Since 2012) as compared to others.

Yii: As Yii is an old framework (Since 2008) and has many developers associated with it already, it offers better support to developers with it’s larger community.

Read More: 11 Top Programming Trends To Look For In 2017


 8) AUDIENCE:

Laravel:: Laravel is a very focused framework which targets only web developers.

Yii:: Yii is for a broader set of audience. It caters to beginners, web developers, system administrators, media and publishing and research & development.

Read More: 12 Top PHP Frameworks For Startup Web Development

CONCLUSION OF LARAVEL VS YII:

In the war of Laravel vs Yii, there is no doubt that Laravel is the largest used PHP framework in recent times and offers you numerous features to choose from. If you are trying to build a large scale web application or an enterprise grade app then Laravel is the best choice you can make. However, if you are looking for a framework that offers simple development opportunity and your goal is to develop small to medium grade applications then Yii2 is your cut.

At ValueCoders, we have a large PHP development team who are adept at both the frameworks. If you are looking to hire Laravel developers then we can provide the same. However, if you are facing the above discussed difficulties then you can hire Yii developers from us too.

Web & Mobile app development

About the Author

Mantra is a Business Consultant & strategic thought leader bridging the divide between technology and client satisfaction. With 12 years of knowledge, innovation and hands-on experience in providing consultations to Startups, ISVs & Agencies who need dedicated development & technology partners. He has also lead to the delivery of countless successful projects.
Blogging is his passion & he shares his expertise here through ValueCoders.. Follow him on Twitter & LinkedIn

15 comments

  1. I made my websites on Yii framework and I found it is best. The main advantage of the Yii framework is that it is suitable for any kind of project. It provide various technological benefits to business. Nowadays Yii framework is emerging as most powerful PHP platform. To know more about the Yii framework contact here http://bit.ly/2D9n1K1

  2. “However, if you are looking for a framework that offers simple
    development opportunity and your goal is to develop small to medium
    grade applications then Yii2 is your cut.”

    Lol, that was funny. FYI, Yii can do everything what Laravel can. Laravel is a great framework, one of the great frameworks, nothing more. Please, don’t sell utopias, there is no silver bullets.

    PD: I’m an ex-CodeIgniter lover and former Laravel user

  3. I use Yii 2 for projects that have big data and complex flow, I found it best. Also very useful if you are senior developer and want to develop your system in fast way it is secure and fast. Yii 2 have a strong and simple documentation with examples. Simply Yii 2 is best for large and complex systems.

  4. First thing is, Laravel has a big community compare to the Yii. Like if any big business application development required then you have to build that big application in Laravel platform. As my concern, I would like to say that Laravel is the best among PHP framework.

  5. From what I’ve seen on multiple forums, people, who started working with Laravel and tried to master Yii later claimed that it was uncomfortable and odd to deal with. And vice versa. At the end of the day, there’s no clear winner here. It’s up to you to decide which one suits you best according to your requirment

  6. I used both of them. Yii2 is very good and offers quicker ways to maintain many tasks out of the box.
    The point that leads me to migrate from Yii2 to Laravel is Laravel’s Eloquent the DB ORM used by Laravel. It offers semi complete tools to deal with Many to Many relations through conjunction table , pivot,.
    The good news, Yii2 ORM will be have new features in next Yii2 ver. 2.0.13 which will cover the limitation with Many to Many relations:
    https://github.com/yiisoft/yii2/issues/2900

  7. I think Yii2 is way better than laravel.
    It has all laravel functionalities and more. All above mentioned facets are enough for me to use Yii over laravel.

    Yii2 have more standards. and consistency.
    I’m using Yii1 for 2 years, and Yii2 for few months.
    You can’t say it is better because laravel used worldwide more than Yii.

  8. I do not agree with your point related to Routing, totally. Actually, I think is validating or whitelisting of each url is required in the current scenario for security purposes. sometimes a path from outside is executed in our server. If we have a list of whitelisted url, isn’t it good.

    In most of the operation CRUD is required only once command can make all the routes related to crud operations.

  9. I do not agree with your first point that is Laravel does not support scenario based validation. There is a concept of DI(dependency injection) whenever you call a method of a controller you can inject a Request class in it. This request class can be different for both of the scenarios for update and add.

  10. Taking about Yii2 documentation its hard for beginners to understand Yii from it’s documentation on the other hand it from Laravel documentation beginner can start it easily.

    1. I would prefer a doumentation which is quite comprehensive and lucid. CodeIgniter Documentation is quite complete. CI developers dont need to google around much, same is the case with CakePHP. Yii attempts to provide a comprehensive documentation with examples, thus the intended audience is not just beginers, but also the intermediate/experienced level developers.

      Ahmed you are right that Laravel Documentation is easier, and this is because its intended for perhaps beginers mainly. However when developer becomes mature with time, and willing to explore further, documentation is of not of much help because of lack of comprehensivity, and then one has to turn to class reference.

      Now regarding class reference, I find class reference documentation of some frameworks far-far better than Laravel. I find mainly 3 big issues with class reference of Laravel.

      1. No description for function Parameter
      2. No description for function Return
      3. Not much of description is present for function itself.

      Apart from this laravel lack examples in its class reference.

      CHECKOUT THE DIFFERENCE YOURSELF

      Here is Model Class Reference of Laravel and Yii2

      https://laravel.com/api/5.2/Illuminate/Database/Eloquent/Model.html
      http://www.yiiframework.com/doc-2.0/yii-base-model.html

Leave a Reply

Your email address will not be published. Required fields are marked *

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