Welcome Guest, Not a member yet? Register   Sign In
HMVC the right way ?!
#9

(05-27-2015, 12:18 PM)frocco Wrote: I am not understanding this. If you have an Auth Module, most likely every module in your app might require it.
Are you talking controller to controller calls or a view calling different controllers?

I really do not understand the correct way to use HMVC and would love to see a tutorial.

I think the problem here is that a couple of terms are getting mixed up: packages and modules. CodeIgniter supports packages out of the box, unlike modules - which is just a term people use for packages under one of the two HMVC systems, really.

Taking your Auth Module as an example:

- The package would provide libraries, config files, etc that would implement the underlying guts of the authentication system. This is perfectly valid and a great use for packages. This is also a fine use for HMVC "modules", since you would be using it like a package of libraries and models.
- The module version could theoretically also have a controller that provides the login, forgot password, etc. In this case, all of this functionality should be contained within the module. It should not reach into other modules for anything.

There's basically 2 uses of HMVC, then:

the first that is a collection of shared code that focuses on a fairly narrow topic (like Auth). This stuff is specifically there to be used by other code and can be thought of exactly how CodeIgniter's packages is used.

The second case is more like a CMS' full-blown module. In these cases, it should all be self-contained. If you think of a Blog module, it would provide code to display the posts, create new posts, etc. All of its activity is based around the blog and there it should never reach into other modules (unless it's a "package" with shared libraries), and other modules should reach into it.

And that is where the original question comes into play: if modules are supposed to be clean and separated from each other, how can we easily display that information in other places where controllers outside of this module are running? In WireDesignz' HMVC solution, you can call Modules::run() to call a controller from another module and get some content back. This is a bad thing in CodeIgniter's case, because it wasn't designed to work that way and can cause problems with multiple instance of the CI singleton in play, confusing things horribly.

The best solution is to create a library that you can load from other controllers (think of it as a package here) and things work as they should.

Hopefully this makes sense. I'm not 100% sure it does. The waters are pretty muddy, depending on the exact use. Smile
Reply


Messages In This Thread
HMVC the right way ?! - by RogerMore - 05-26-2015, 02:10 AM
RE: HMVC the right way ?! - by gadelat - 05-26-2015, 03:15 AM
RE: HMVC the right way ?! - by kilishan - 05-26-2015, 07:08 AM
RE: HMVC the right way ?! - by Narf - 05-26-2015, 01:16 PM
RE: HMVC the right way ?! - by kilishan - 05-26-2015, 10:32 PM
RE: HMVC the right way ?! - by mwhitney - 05-27-2015, 08:24 AM
RE: HMVC the right way ?! - by frocco - 05-27-2015, 12:18 PM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 06:49 AM
RE: HMVC the right way ?! - by kilishan - 05-27-2015, 10:14 PM
RE: HMVC the right way ?! - by kilishan - 05-27-2015, 10:29 PM
RE: HMVC the right way ?! - by frocco - 05-28-2015, 05:47 AM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 07:06 AM
RE: HMVC the right way ?! - by RogerMore - 05-28-2015, 12:06 PM
RE: HMVC the right way ?! - by josetrindade - 06-02-2015, 10:30 AM
RE: HMVC the right way ?! - by RogerMore - 05-29-2015, 07:24 AM
RE: HMVC the right way ?! - by kilishan - 05-29-2015, 07:30 AM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 08:05 AM
RE: HMVC the right way ?! - by Narf - 05-29-2015, 09:50 AM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 12:09 PM
RE: HMVC the right way ?! - by Narf - 05-30-2015, 05:47 AM
RE: HMVC the right way ?! - by mwhitney - 06-01-2015, 08:13 AM
RE: HMVC the right way ?! - by Narf - 06-01-2015, 10:21 AM
RE: HMVC the right way ?! - by no1youknowz - 06-01-2015, 08:33 PM
RE: HMVC the right way ?! - by RogerMore - 05-29-2015, 08:16 AM
RE: HMVC the right way ?! - by RogerMore - 05-31-2015, 01:48 PM
RE: HMVC the right way ?! - by frocco - 06-01-2015, 05:26 AM
RE: HMVC the right way ?! - by kilishan - 05-31-2015, 10:05 PM
RE: HMVC the right way ?! - by RogerMore - 06-01-2015, 10:49 AM
RE: HMVC the right way ?! - by mwhitney - 06-02-2015, 12:06 PM
RE: HMVC the right way ?! - by frocco - 06-01-2015, 12:02 PM
RE: HMVC the right way ?! - by RogerMore - 06-01-2015, 03:12 PM
RE: HMVC the right way ?! - by frocco - 06-03-2015, 03:41 AM
RE: HMVC the right way ?! - by RogerMore - 06-01-2015, 10:25 PM
RE: HMVC the right way ?! - by no1youknowz - 06-02-2015, 09:09 AM
RE: HMVC the right way ?! - by RogerMore - 06-03-2015, 12:40 AM
RE: HMVC the right way ?! - by mwhitney - 06-03-2015, 06:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB