Should I do this with another module in the HMVC encoder?

I am just starting to use HMVC in Codeigniter. The main module is a news / blog site called "blog." I want users to be able to log in to comment, so I have authentication files (actually actually). Now I also want users to have their own profile pages that show their placement statistics and personal information. Users can also have a private messaging system in which they send messages to each other.

Being new to HMVC, how do I modulate my code? I currently assume that the good will be

  • 'blog' - Blog / News Archive
  • 'auth' - User Authentication
  • 'users' - User profile + Private message

Both "blogs" and "users" will call "auth", which also displays a small widget in the corner of the page that shows Register | Register if you are not logged in and Welcome John! Profile | Inbox | Settings if you are logged in as John.

Or do I need to combine "auth" and "users" together, or separate "users" into "profile" and "messaging"? What will the hierarchy look like if you want to create an HMVC structure?

+4
source share
1 answer

It really depends, and it is up to you.

If you want the comment system to be applied to other modules on some day, definitely make it your own module. If this is only related to blogs, you can leave it in the blog modules as your own controller. modules::run() and $this->load->module() can also be useful here, invoking the controller from anywhere to get view fragments to display comments.

I would probably create everything that he has.

It is almost impossible to be truly 100% modular, there will always be certain dependencies. The best you can do is try to organize it in a way that makes sense for your specific project. In general, modulate as much as possible - if you decide to get rid of blog comments once, you can simply remove the comment module.

+1
source

All Articles