Welcome Guest, Not a member yet? Register   Sign In
HMVC: Base.php vs. Ci.php
#16

[eluser]Maarten Troonbeeckx[/eluser]
Damn, this is frustrating :/
I'll try to explain myself again, hopefully better this time.
If I fail, you can call me a retard officially, instead of insinuating it Wink

I have the MX folder in the /third_party folder, both MY_Loader and MY_Router are in my application/core directory.

My understanding about what HMVC is:
- Modular separation (structure models/views/controllers in separate module folders)
- Ability to run multiple controllers in your application code (Modules::run())

If I extend MX_Controller a CI class (Base.php) is instantiated and used in MX_Controller's __get() to access loaded models/libraries, ...
If I extend CI_Controller a CI class (Ci.php) is instantiated which "decorates" the original CI_Controller with a static $APP variable, MX_Loader, ...

Btw, with CI_Controller I don't mean the standard CI_Controller, but the one that gets modified by Ci.php in the HMVC package!

[quote author="wiredesignz" date="1308964018"]In Base.php the CI class extends the CI_Controller class which holds the application object (CI::$APP) used to contain all of the CodeIgniter core classes. This allows you to use multiple controllers (HMVC) in your application. Your controllers must extend the MX_Controller class.

In Ci.php the CI class does not extend the CI_Controller, but still allows the use of the same code base to access the application object and the core classes. This only provides your application with modular separation, not HMVC. Your controller must extend the CI_Controller class.[/quote]

Your reply suggested to me that extending MX_Controller allows me to use multiple controllers and extending CI_Controller only provides my application with modular separation. This made me think that using multiple controllers was disabled in the second case and made sense to me...

[quote author="wiredesignz" date="1309055668"]Nothing is disabled. Things will function differently if you extend MX_Controller. HMVC is merely a design pattern you use in development, it's not a rule. There is nothing to stop you using modules::run (HMVC) without extending the MX_Controller class.[/quote]

Turned out I was wrong.

[quote author="wiredesignz" date="1309109413"]There are two options because they each have different requirements. There is no point loading and extending MX_Controller if you do not need to use HMVC. All you are doing is slowing down the application execution unnecessarily.[/quote]

But I do want to use HMVC, especially the modular separation part Wink
And everything seems to work the same way, whether I extend CI_Controller or MX_Controller.

So again, my question remains:
What's the difference between extending CI_Controller (not the regular one!) and MX_Controller, since in both cases you end up with an app allowing modular separation and the ability to use multiple controllers?

Hope I'm making more sense this time.

Grtz, M.


Messages In This Thread
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 11:56 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 02:06 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 02:59 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 05:06 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 05:12 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 02:38 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 06:02 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 07:30 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 08:24 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 12:26 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 03:34 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-26-2011, 05:24 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-26-2011, 06:30 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 12:45 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 12:57 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 03:03 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 03:28 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 04:39 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 02:53 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-28-2011, 01:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB