May
13
2009
0

Yii Framework controller and view path convention

Yii Framework has just upgraded to 1.0.5, really glad that Qiang could keep up the momentum to release an update every month. We strongly believe with this level of activity, this open source project will soon becoming the most popular and comprehensive PHP framework. However the only problem this brings is the question "To upgrade or NOT to upgrade?". For a real life project, it's bit hard to keep up with the monthly upgrade, especially when things are constantly changing and improving. Some upgrade really brings the benefit of stability and versatility to the framework, but there are bad times...

Yesterday as usual, we have upgraded our Yii version to 1.0.5, and one of the project we are working on suddenly stopped working almost completely. That was because of a little change in the view path naming convention. To read more about the issue please refer to Issue 307.

To avoid this, please keep this naming convention in mind:

  • Name controller ID in lowercase only with the very first letter/word capitalized.
  • If a controller ID has multiple words try to separate them using underscore '_' or hyphen '-' to concatenate them, NOT capitalize any following words
  • All view path/directory should be all in lowercase and with underscore '_' or hyphen '-' for concatenation.
This directory naming convention should prevent any problem on both Windows or *nix platform.

The only last thing we didn't really agree with Qiang is that a controller would only be accessible by only one URL, not both capitalized or lowercased word(s), simply because an URL should be unified and universal. We would like to leave this discussion to all the Yii enthusiast.

Copyright Orite Group Pty Ltd | Powered by WordPress | Theme: Aeros 2.0