I\'m currently working on my own PHP Framework, and I need some help figuring out if I\'m going in the right direction or not...
The framework is both for my own use
i would suggest you to use a bootstrap.php that manages all the routings so you never run into issues like "i wish i could nest one folder more into my admin module".
i also wouldnt use modules and keep the default controllers right inside the controller/ dir and the admin controllers inside the controller/admin dir. same for models and views.
btw its really not clever not to share the models between different parts of your application, they are going to be the same in 99% of all cases. thats why mvc is so powerful. sometimes you even can share some of the view parts inside your app between the front- and backend.
One Solution for admin routing is what CakePHP does, you first define a configuration for the admin string and then in your controller use actions with a specific naming convertion
//Configuration ============================
Configure::write("admin_routing" , true );
Configure::write("admin_prefix" , "admin" );
//Controller ===============================
class MyController extends AppController{
function index(){
//Will map to /mycontroller/
}
function admin_index(){
//Will map to /admin/mycontroller/
}
}
You can generalize this by using a routing system just look how your favorite framework does it
On another note
Hope this helps
I know this was asked a long time ago, but I was in the exact same situation a few days ago.
The asker's proposed solution is basically what I went with, oddly enough. Basically, I borrowed a concept from ASP.NET MVC2 called "areas". Areas are sections of the site that have their own controllers and view (also models, but I don't know why ... models should generally be universal). So this is very similar to your initial idea.
In any case following their folder+routing structure made quite a lot of sense for my application (admin type area, a users area, and another level in between). Take a look at it and you might find some success there.
My routing just takes into account areas. The routes are hard coded, so if I need another area I just adjust my routing file. Oh also, my autoloaders are set to look in the area folder if $area is specified.
/admin/team/add/
is read as, Area: Admin, Controller: team, Action: add
whereas
/team/add/
would read as, Area: [none], Controller: team, Action: add
Folder structure kinda like this:
app/
areas/
admin/
controllers/
views/
staff/
controllers/
views/
controllers/
models/
views/