When comparing Grails vs Yii, the Slant community recommends Yii for most people. In the question“What are the best web frameworks to create a web REST API?” Yii is ranked 16th while Grails is ranked 28th. The most important reason people chose Yii is:
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.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Grails is highly scalable
Grails is an abstraction over Spring and Hibernate. This makes Grails applications fast and scalable. This is because both Spring and Hibernate are themselves scalable.
Pro More than 900 plugins
Grails is a full-stack web framework, not just MVC. It contains a lot of stuff out of the box, but it doesn’t enforce it. It contains over 900 plugins which provide a Groovy API for a lot of useful and well-known Java libraries. And what is more important is that they are super easy to install!
Pro Very fast setup and scaffolding
Setting up a new project is quite fast and code generation (scaffolding) saves you a lot of time. It also uses a convention over configuration principle which helps you bypass all the configuration trouble.
Grails also comes with a reloading mechanism out of the box.
Pro Easy to use
Grails is designed to be a rapid development framework with a straight learning curve. It advocates convention over configuration. Extensibility is very simple when using plugins (there is a lot of them). One command in the console – and all the dependencies and configurations are managed for you.
Pro Great UI design alternatives
Do you need something advanced in the UI? You can either create it in GSP with an addon of CSS/JavaScript or you can find a plugin that will do the work for you. Plugins include integration with Bootstrap, jQuery, Yeoman and much more.
Pro Great documentation and community
The Documentation section is actually a wiki, which can be modified by any logged in user. It has an official manual, tutorials, screencasts, a sample app and much more. If that does not do it for you, then there are countless third-party tutorials, more than 12k questions on SO and much much more
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 Grails is a fairly complex framework
Grails is a pretty heavy piece of software. It's functionality is covered by GORM (Grails' Object Relational Mapping) which is a facade for hybernate and by Spring MVC.
Everything is glued by core Spring and furthermore, Grails adds another level of abstraction on top of all this. These things may create some trouble down the road when debugging.
Con Too obtuse and JVM centric
If you're a big fan of the JVM and have mastered all its goofy quirks, Grails might be a good choice, but there are other frameworks out there that are more straightforward and easier to use.
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)