Spring MVC vs Yii
When comparing Spring MVC vs Yii, the Slant community recommends Spring MVC for most people. In the question“What are the best backend web frameworks?” Spring MVC is ranked 11th while Yii is ranked 21st. The most important reason people chose Spring MVC is:
The official documentation covers virtually everything. The official website also has a series of great tutorials in video and text formats. There are links to Github repositories for Spring sample applications and there are also a lot of third-party tutorials out there for the fact that Spring MVC is so widely used by many experienced developers.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Great documentation that covers almost everything
The official documentation covers virtually everything. The official website also has a series of great tutorials in video and text formats. There are links to Github repositories for Spring sample applications and there are also a lot of third-party tutorials out there for the fact that Spring MVC is so widely used by many experienced developers.
Pro Spring MVC has a massive community
Being the oldest and most used JVM web framework, means that Spring MVC has a massive community of followers who are very helpful and have provided numerous tutorials and answers on SO.
Spring even holds an annual conference called SpringOne. The Spring forums and SO are great places to ask and get help about anything Spring related. The website blog and newsletter keep developers informed on every news related with the framework.
Pro Spring apps are highly scalable
Applications are meant to scale as the framework is used in large-scale applications worldwide. Components like EhCache are used to scale memory cache and it also contains components used for parallel processing.
Batch enables processing of large volumes of records and job processing statistics.
Pro Spring has an extensive ecosystem
It is based and is dependent on the Spring Framework, therefore it benefits from tools like for example Roo and Spring Tool Suite and many more tools included in the Spring Framework. All Maven dependencies are available in a public Maven repository.
There are also 3rd-party solutions for Spring, such as MyEclipse which includes scaffolding capability for Spring MVC.
Pro Rapid development through code scaffolding
Yii takes care of repetitive tasks through Gii, a web-based scaffolding tool. Gii takes care of code generation and creating code templates for:
- Models
- Controllers
- Forms
- Modules
- Extensions
- CRUD controller actions and views
- There are a lot of scaffolding templates made by community for Gii, that improve generated code functionality by a lot.
- Gii is very easy to extend yourself.
Pro Comes with important security standarts
Since security is a crucial part of any application, Yii comes with great security features out of the box to help developers create a secure and reliable application. These security features contain but are not restricted to:
- Input validation
- Output filtering
- Features against SQL injection
- Cross-site scripting prevention
Pro Highly extensible
Yii is built to be extremely extensible. Virtually every component of the framework can be extended programmatically. For example, if you want to add a unique id to your views, it's very easy to do:
namespace app\components;
class View extends yii\web\View {
public $bodyId;
/* Yii allows you to add magic getter methods by prefacing method names with "get" */
public function getBodyIdAttribute() {
return ($this->bodyId != '') ? 'id="' . $this->bodyId . '"' : '';
}
}
Pro Integrated with a testing framework
Yii makes use of Codeception, a great PHP testing framework that helps developers run their tests. They can be unit, functional or acceptance tests since Codeception supports them all.
Pro Lots of plugins available
Yii has about 2000 addons hosted on Yii's official website. These addons significantly decrease development time and increase the developer's efficiency.
Pro License
Yii is free and open source and is distributed under the BSD License.
Pro Strong community support
Yii has a strong and rather large community behind it. This is proven by the great number of blog posts, tutorials, guides and reviews on the Yii framework as well as the great number of extensions developed for it.
Pro Easy to install
Yii uses Composer to handle it's dependency installation. This is rather easy and not very time consuming, although it should be noted that Composer is very resource-intensive considering what it's job is. But that is not really Yii's fault.
Pro Best framework for CRUD operation
Yii Framework Provides most of features require for crud functionalities like GridView, Listview and DetailView (with jquery search and validation functions) by generating using GII.
Pro Highly extensible without effort
Cons
Con Updating and code maintenance can be a grueling task if you are a beginner
Updating your project is manageable if you’re already familiar with the framework and the project itself, but if you’re just diving in it can be a little overwhelming and hard.
Con Bloated legacy DI API
Spring DI is bloated and rather complex in comparison to CDI.
Con Complex and not newbie friendly
Spring MVC architecture although simple has a lot of layers and abstractions which can be hard to debug if problems arise. It is also highly dependant on the Spring core.
It's an old and mature framework that has numerous amount of ways to extend and configure it – and this actually makes it fairly complex.
Con Lacking in UI development
While actually very good and with a very complete and rich feature set to develop and maintain code on the server side, it still doesn't provide any rich framework for building good user interfaces.
Con Unnecessarily slow, bloated, complex, convoluted, wordy, and verbose
Spring is convoluted and XML-ridden. Deploying things on the JVM has always been a pain in the nipple and nothing has changed much since the 90s. All things Java-related are wordy, verbose, and a waste of developer time.
Con Slow Prototyping
If you are looking to build a quick prototype fast and easy, Spring isn't going to help much. It's very large and quite hard to grasp if you are just beginning with it.
Con Can be hard for beginners
Since Yii requires developers to write code following certain rules, or in other words, it requires developers to follow the "Yii way of doing things" it can be hard for beginners to warm up to it and start using it right away.
Con Not very good at many to many relations
(but there is a good plugin, namely CAdvancedArBehavior extension to do this)