Category: Yii

Alternative to the beforeAction() event

January 11th, 2010, 5 Comments

I often see that when someone needs something executed on every page request before anything else is executed, they usually put it in the controller beforeAction() method. Things you might want executed on every page request might be, for example (so you know what I’m talking about): Handling the layout Cleaning all GET and POST […]

Table prefixes

April 9th, 2009, 5 Comments

One question I hear many people ask around the Yii forum is how to use table prefixes with ActiveRecord. I believe the best way to solve this problem is to extend CActiveRecord::tableName(). Now you can either extend this method in every active record class you would like to use a prefix manually, or you can […]

Safe attributes tip

February 19th, 2009, No Comments

In my last two posts [1, 2] I explained how to define scenario-based validation rules and safe attributes. Something I have noted is that whenever I end up specifying an attribute as “required” in the validation rules(), I also always end up specifying it as “safe” in safeAttributes() under the same scenario. This got me […]

Safe attribute scenarios

February 17th, 2009, 3 Comments

If you read my last article on validation scenarios then you may understand why in different scenarios you may need different attributes to be required. However you may have noticed a missing link – what if in different scenarios you also need different attributes to be considered as “safe”? If you have no idea about […]

Validation scenarios

February 16th, 2009, 16 Comments

As of Yii 1.0.2 you may now define validation scenarios. This is very useful if for instance you have multiple places in your application that you validate a model, but in each instance you may want different validation rules. For instance, perhaps in your user registration form you want to have the “username”, “email” and […]

Running your Yii app and configuring it

December 29th, 2008, 12 Comments

Unlike in CakePHP, it is mandatory to use the shell tool (called yiic, similar to CakePHP’s “Bake” script) to start off your application as it creates the workspace architecture (The Yii package does not come with an application bare-bones, only framework code). Yiic generates .htaccess files with rules that forwards user requests to index.php where […]

My findings in Yii and comparisons to CakePHP

December 20th, 2008, 26 Comments

Since I have found out about Yii I have been using it to work on a “dummy” website with features that are generally used across a large variety of websites (e.g. news system, user system, authorization, etc). This is also exactly what I did with CakePHP when I first started learning it, and the reason […]

This New Blog

November 14th, 2008, No Comments

I’ve been wanting to and been procrastinating about creating a new blog for the last year.  And now, on an evening with not much to do, I have done exactly that.  On this blog I will share my thoughts on web development, which for the most part will be on PHP and it’s various frameworks […]

Feed

http://php-thoughts.cubedwater.com / Yii