domenica, giugno 02, 2013

A good cookbook for Yii development

I just finished reading Alexander Makarov's Yii Application Development Cookbook that I found a really valuable resource to keep at hand if you are developing a web application using Yii.
In its thirteen chapters you are provided with lots of recipes that open your eyes on what the framework does for you under the hood, and on what you can do with minimal effort to improve your application.
The book can be really a time-saving resource: by reading the recipes provided, I ended up many times thinking "If I hadn't read this here, I would have reinvented the wheel, should I have faced the same problem described." For instance, I didn't know about decorators, custom input widgets, some methods automatically called as event
handlers, reusable controller actions, etc., and I found out that a very easy implementation of these concepts is actually just a few lines of code away.
Even for things that I already knew before reading the book, I found it very interesting to compare my solutions with what was described in the book, since I always try to write my code "in the right way",
following the best practices, and I am eager for improvements. Ideas and implementations of simple table inheritance, zii widget customization, role based access control, etc., fell for me in this
category.
Last but not least, the book provides very useful hints for the deployment, when one should fine-tune the application in order to improve the performances.
The only things that appeared to be wrong, from my point of view, is the use of "get", "put" and "post" HTTP methods, that in some recipes seem to be used in the wrong way. In a web application you should never allow somebody to delete something by clicking on an ordinary link, and that means that you should check whether the request is done via the "post" method (Yii provides a postOnly filter for that), and the cookbook should stress that. Another point is that in RESTful applications "post" is used to store new data, while "put" to update data already existing, not viceversa (this is already fixed in the errata page).