Laravel vs. Yii: 8 Things You Should Know
Laravel vs. Yii: 8 Things You Should Know
After a year spent working with Laravel and even longer with Yii, this team breaks down where each framework shines and where they fall flat.
Join the DZone community and get the full member experience.Join For Free
Learn how error monitoring with Sentry closes the gap between the product team and your customers. With Sentry, you can focus on what you do best: building and scaling software that makes your users’ lives better.
If you have a knack for building web apps for your business in PHP, Laravel and Yii are familiar names to you. Laravel is indeed a great framework and is perhaps be the best nowadays. In our previous blog, we supported that idea. However, when our PHP team at ValueCoders was trying to move to Laravel from Yii, they came across a few things that can't be overlooked. This brings us to our topic: Laravel vs Yii: 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 have been using Yii for about three years and started working with Laravel last year. Yii2 was good, but before starting to work on Laravel, we got the feeling that it would be a far smarter framework than Yii.
However, here is our experience. We found the following eight differences while researching Laravel and Yii.
Laravel: No scenario-based validation is available in the default package of Laravel. It does not provide any construct to validate a model in different scenarios. Moreover, there is no way to define fillable attributes based on the scenario. You will have to custom code everything.
Yii: Both massive assignments of the model from the request parameters and its validation can be done based on the scenario.
Client Side Validation
Laravel: No default support is available on Laravel.
Laravel: We are supposed to declare routes to each and every action in all controllers. We found this to be quite odd! Besides, why is the protected function of the controller is being accessed from outside if provided in the route? Somehow, we believe that it should be the task of the 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 to mention routes for each and every action. Routes of actions are picked up by default. Same with CodeIgniter as well.
Laravel: No default support. Many projects have an admin panel for CRUD functionality from various tables.
Yii: Yii 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.
Laravel: Laravel is said to have the best documentation, and we believe that it's sometimes not possible to document everything. But somehow, we were not able to appreciate the effort. We personally believe the documentation could have been organized better and written in a more generic way. We often have to check the Class Reference.
Yii: On the other hand, though Yii does not have a very strong documentation, it's pretty organized. Moreover, it does not have a steep learning curve. If you are following the docs, you can easily start with basic coding.
Laravel: "The PHP Framework For Web Artisans." Even after working for one year, we are still trying to feel like artisans. 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.
Resources and Support
Laravel: Laravel has a large community with good support, and it's growing every day. However, it is a new framework (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 its larger community.
Laravel: Laravel is a very focused framework which targets only web developers.
Yii: Yii is for a broader audience. It caters to beginners, web developers, system administrators, media and publishing, and research and development.
There is no doubt that Laravel is the largest used PHP framework in recent times and offers 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 web application development opportunity and your goal is to develop small-to-medium grade applications, then Yii is your cut.
Opinions expressed by DZone contributors are their own.