I just recently started using Yii and must say that it's fantastic, but… What am I wondering here is if it's possible to use some kind of nested controllers. As it is now, I have a UserController with methods like actionViewProfile, actionEditProfile and actionViewMail. I think would look better and be more convenient if I could have this controller structure:
controllers/
UserController.php
user/
ProfileController.php
MailController.php
With URLs like user/profile/edit instead of user/editProfile. I realise that you probably could use patterns to achieve these URLs, but then I'd have to do it for almost all controllers, since this is the way I think.
So, is this possible? Or should I use some entirely different method? If there's no relatively easy way to do it, I think I'll just create a ProfileController (in the root of the controllers directory) and hope I won't have to create any controllers with similar names or exactly the same one.
It is actually possible to support format user/profile/edit (by overriding CUrlManager), but this is at the cost of performance degradation, because the URL manager needs to check if there is "user" directory and a "ProfileController.php".
Yeah, I don't really recommend doing that. Prior to using Yii I was trying to create my own framework and implemented the behaviour mezoni is describing. Not only is it a pain in the butt to implement in what I'd call a clean way, if you've taken a liking to nested controllers (like I have) there'll be a whole lot of file_exists:ing and whatnot. I don't think it's worth it. Besides, I happen to think that "user.profile" looks just fine. 'cuz it does. O ho ho.
That's right. When Yii sees user in the route, it first attempts to look for UserController. If not found, it will look for a directory named 'user' and search below.
Strange, but it doesn't see it there either. Or maybe I'm too sleepy now and can't see some typos. OK, thanks for your help. I'll read the UPGRADE file tomorrow and sort that out.