In MVC its like http://www.yourdomain.com/sampleController/sampleAction/
and if you call just /sampleController/
then /sampleController/indexAction/
and if you just call / then /indexController/indexAction/
fires.
Of course there are exceptions but thats more or less the convention.
Zend has something smilir. They call it Modules.
They are basically just folders that contain an MVC logic each. So you can call /Module1/Controller/Action/
. If you just call /Module1/
then /Module1/indexController/indexAction/
fires. Its convinient if you have a huge project because you can structure even more but its annoying if you have just a little project.
So I really like the Idea of HMVC/PAC and want to adopt it in my framework.
Did I understand it correctly that its basically the same as Zend does but with unlimited nested modules?
So for example I have /sub-project/sub-sub-project/controller/action/
?
And what is the convention if I call /A/B/C/D/.
Does it mean Action D in controller C in module A/B? Or IndexAction in Controller D in Module A/B/C?
Lets put it in an example:
Content
ToplistController
AdministrateAction
IndexAction
ContentController
ToplistAction
Users
Chat
RoomController
IndexAction
I now call the URL /content/toplist/
.
For the URL /users/chat/room/?room=1
the example makes it obvious because there is only one possibility. But is it the right one? Is there a convention to uniquely adress the right action in the right controller?
My first idea was to "guess as little as possible".
So I first check if the url is directly matched to an action.
And if there is a controller/module called the same with an index action, it just can not fire if a match on a "higher level" is present.
If this is not the case I see whether the url directly matches a controller and append IndexAction.
If this is not the case too I look for a module and guess IndexController and IndexAction and if this is not the case I look for an module called index.
But i would like to avoid this if/else stuff and the file system accesses. So I wondered how the convention is. Or is there even one? I could not find any examples!
Or does something like calling IndexAction if none is specified just not done but every "short url" has to be specified in seperate routing logic?
Or have I completely mis understood the concept of HMVC/PAC?
FYI: I included the php tag because I am doing my framework in php and want to know about the conventions in php. I have often seen differences in other programming languages.
There is no official framework-independent convention.
URIs identify resources. How some framework maps those URIs to internal application functions is up to the framework. For instance if you want to do REST, you wont have actions at all, because actions are implied by the used HTTP verbs, e.g.
whereas the same in a "routed" framework could be something like
with both URIs somehow mapping to the mechanism in your application that knows how to delete.