Welcome Guest, Not a member yet? Register   Sign In
How the heck should I structure a HMVC project?
#1

[eluser]gunnarflax[/eluser]
Hi!

I'm trying to create a backend and a frontend for a HMVC project and this is my first time working with a HMVC structure. What feels most logical to me is to have the frontend controllers in the controller folder and the backend in the modules folder.

Code:
-- application
---- models
---- views
---- controllers
---- modules
------ backend

Then it seems to me that it would be best to have all backend-related modules in it's own module directory within the backend module, but I don't even know if it's possible to nest modules.

If I don't have it like above how shall I build it? Should I have only one controller in the backend module which handles all the navigation and "puttogetherness" of all the other modules? Should the frontend utilize the same modules as the backend so I wouldn't really need to nest modules?

As you can see I have absolutely no idea how to do this. Please come with suggestions Smile
#2

[eluser]Twisted1919[/eluser]
the best solution i found when working with hmvc is like:
Code:
modules
--post
---controllers
----admin.php (handles the admin tasks for the post.php controller)
----post.php (the main controller)

--products
---controllers
----admin
----products.php

--forum
---controllers
----admin (in case the module is more complcated, we can put the admin controllers in a folder)
-----thread.php
-----some-other-admin-controller.php
----forum.php
----thread.php

In the above solution, you will reach your modules like
www.host.com/post (reads post.php controller)
www.host.com/post/admin (reads the admin controller)

Also you can add following routes:
Code:
$route['admin/([a-z 0-9~%.:_\-]+)/(.*)']    = "$1/admin/$2";
$route['admin/(:any)']                      = "$1/admin";

so that you access the module admin more naturally, like:

www.host.com/post (reads post.php controller)
www.host.com/admin/post (reads the admin controller)
#3

[eluser]jblack199[/eluser]
I personally created an admin folder in my controllers and my view folders for my site. Helps me to truly keep all my admin functions away from my front end functions..
#4

[eluser]gunnarflax[/eluser]
[quote author="Twisted1919" date="1313188927"]the best solution i found when working with hmvc is like:
Code:
modules
--post
---controllers
----admin.php (handles the admin tasks for the post.php controller)
----post.php (the main controller)

--products
---controllers
----admin
----products.php

--forum
---controllers
----admin (in case the module is more complcated, we can put the admin controllers in a folder)
-----thread.php
-----some-other-admin-controller.php
----forum.php
----thread.php

In the above solution, you will reach your modules like
www.host.com/post (reads post.php controller)
www.host.com/post/admin (reads the admin controller)

Also you can add following routes:
Code:
$route['admin/([a-z 0-9~%.:_\-]+)/(.*)']    = "$1/admin/$2";
$route['admin/(:any)']                      = "$1/admin";

so that you access the module admin more naturally, like:

www.host.com/post (reads post.php controller)
www.host.com/admin/post (reads the admin controller)[/quote]

I've found this solution on several sites and it seems to me like the best way to keep a truly modular structure Smile Thank guys, I will continue with this one.




Theme © iAndrew 2016 - Forum software by © MyBB