I have my own framework with a request handler and everything. I first started off without a modular approach so just one folder controllers where all the application controllers were located. Now I want to convert it to modules, so every module has his own controller, model, views, forms and so on. This is in not problem but the problem starts when using namespaces (php 5.3).
Default controllers are in Application\Controllers, modules are in Application\Modules\<modulename>\Controllers
I have a few options I'm thinking about, you can tell me how you would do it or/and which option you prefer.
Keep in mind that namespaces are used and the used namespaces.
I would go for option #1 but i'm looking forward to here more from you.
I have a moduleloader which do some stuff when you register modules to the application (enable them). I was thinking to just create an array which holds all controllers of a module so if the request has controller login it will check the array for the login controller and than we can manipulate the namespace Application\Modules\<modulename>\Controllers
Negative: You can't have duplicate controllers, lets say 2 modules have a login controller, this won't work or the first one will be shown. (the possibility that this will happen is small but it exists)
My urls will look like this /modulename/controller/action/params so we can fetch the modulename from the url.
Negative: Long urls and I have to create a lot of rewrite rules to create "beautiful" urls, because I want the urls as short as possible.
It's like option #2 but we will have a request_map array which has key url and value the full controller class (namespace + controller)
Negative: Not so dynamic, we have to add them ourselves to the array.
Page 1 of 1
0 Replies - 10082 Views - Last Post: 24 September 2012 - 11:28 AM
Page 1 of 1