As we all here, I’m trying to build an application upon Yii.
I stumpled upon a few questions doing this:
[*]Naming classes and subfolders. I noticed that if my folder structure looks for example like this:
- UserController.php - SomeotherController.php - user/ - - user/profileController.php - - user/etcetcController.php
It don’t work well. I understand why, because the system don’t know wheter to look in the controller ‘user’ for some action called ‘profile’ or to look in the controller user/profile for the ‘index’ action.
My question is, how to solve this?
I thought of two solutions but I don’t know which is the best:
- Renaming my folder to for example, user_sub
so I get this:
- UserController.php - SomeotherController.php - user_sub/ - - user_sub/profileController.php - - user_sub/etcetcController.php
- Or placing my UserController inside the user folder, so I get this:
- SomeotherController.php - user/ - - user/userController.php - - user/profileController.php - - user/etcetcController.php
and call it by user/user/someAction
Which one is the best? Or is there any other solution?
[*]Using a method of another class.
At first, I tried to use
The desadvantage was the impossibility to use parameters in this method, so I had to use flashvar’s, which is quite ugly to do in this situation (imo). So I thought to import the whole class and use the method I need. One problem: how do I import a class in a subfolder? I tried a couple of things, but none of them worked. Or am I missing something and are there other ways to do this?