YII PHP Framework – Review

If you asked me to review YII PHP Framework in a word, I will not hesitate to call it as a friend.

He codes for me, he almost reduces half of my work in the process of web application development. PHP web developers would love this framework than any other PHP frameworks.

Programmer friendly –

To create a user friendly application, you should use a programmer friendly framework like YII. We prefer smart work over hard work, so why should we have to waste time by writing the same code again and again in every project?

Instead of writing code for a particular requirement, you can develop it as a module, it should be flexible to be used and extended in other projects.

To create a user friendly application, you should use a programmer friendly framework like YII. We prefer smart work over hard work, so why should we have to waste time by writing the same code again and again in every project?

Things we have been doing in almost every project.

1. Forms
1.1 Validation
1.2 Create
1.3 Edit
1.4 View
2. Input Sanitization
3. URL Validation/Routing
4. User Role Based Access Control & Privileges
5. List Pages
5.1 Search
5.2 Sorting
5.3 Pagination
5.4 Activate/Deactivate items
5.5 Delete item
6. Login – Captcha/Remember me
7. Registration Form
8. Contact form
9. User Profile settings

Phewww, that’s a big list! Imagine the amount of time we spend for this in all our projects?
If you had spent lot of time for the above list, it’s time to leave all the stuff to YII as he is an expert in it.

Object Oriented Programming

YII provides lot of web development stuffs by default, but you should know to deal with respective classes, it has been completely driven by OOPS.

If you want something more from the existing class, just extend the class and achieve with custom module.
GII Module

If you have visualized YII is a kind of a CMS, no it is not!

YII has an awesome module named GII. This password protected module primarily acts as a code generator, it creates Models, Modules, Controllers, Views, Forms and List Pages based on your relational database schema.

Plan > Design > Execute

Analyze the project, discuss and design a perfect normalized DB, assign foreign keys and let the GII module to write all the code for you. All you have to do is to configure and customize the generated code to fit client’s requirement.

Say Bye to all the Big-Big SQL Queries – ActiveRecord

It’s enough writing Queries all over the project, you will lose control on it, once the project grows beyond a limit.

Create a Model Class for the table and extend it from ActiveRecord. By initiating this Object, you can perform all the SQL operations. It makes fetching and saving data very simple. PHP web developers can now do a hassle-free Web development.

In good old days of Web development, to fetch and save data, you have to write the classical query without syntax mistake, then you have to pass the query in respective inbuilt functions, and then you have to declare bunch of variables, then you have to loop it and even more.

Say Bye to all the SQL Queries, with the help of ActiveRecord, you can achieve the DB related tasks in 2 or 3 lines.
Initiate the object, call the respective ActiveRecord method and it’s done.

YII Relationships

One of my favorite features, you can define relationship between the tables as BELONGS_TO, HAS ONE, HAS MANY, MANY MANY.

How it makes my life simple? Let’s say you have the following tables,

Users
UserFriends
UserFavorites
UserComments

You can define the relationship between each table as property and how the tables are related to each other in their respective model. Once you configure the properties, it will return the data as string or array based on the relationship.

This great feature will help you to get rid of SQL Join family. That is, once you initiate the user model, you can access the friends list, favorites and comments with ease in a couple of lines code.

I have just described a few features of YII, which you have to work on it to enjoy the experience.

Features
1. Data Access Object (DAO)
2. ActiveRecord
3. Caching
4. Scaffolding
5. Authentication/Authorization
6. RBAC
7. Ajax Enabled Widgets
8. Webservice – WSDL & HTTP Authentication
9. Error handling / Logs
10. Security Measurements to prevent following attacks
a. XSS
b. CSRF
c. SQL Injection
d. Cookie Tampering

11. Code Generator – GII
12. Unit and functionality testing

Pollution Free
It controls pollution in code. I am allergic to see 1000 lines of poor code in controllers and models.
YII helps you to achieve the requirements in 2 or 3 lines of code in most of the places.
1. Check the YII Documentation and look for the class which suits your requirement.
2. Pick the Class and Initialize the required Object.
3. Pass your Inputs and get the desired output, it is as simple as that.

Disadvantages
1. Lack of examples over the web.
2. Not easy for beginners.

As a PHP web developer, If you have never heard about OOPS, it’s a good reason to stay away from YII PHP framework.

Contact Our Web Developers

Sep, 04, 2012    Nash Ogden

  Blog, PHP