CodeIgniter Forums
HMVC: Base.php vs. Ci.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: HMVC: Base.php vs. Ci.php (/showthread.php?tid=42956)

Pages: 1 2


HMVC: Base.php vs. Ci.php - El Forum - 06-24-2011

[eluser]Maarten Troonbeeckx[/eluser]
Trying out HMVC for the first time.
Obviously, I always want to understand the code I'm working with to a certain point.
Well, I'm not understanding the following Wink

Why the need for Base.php and Ci.php?
They're almost the same, why use Base.php here and Ci.php somewhere else?
Can someone explain this to me?

Grtz, M.


HMVC: Base.php vs. Ci.php - El Forum - 06-24-2011

[eluser]wiredesignz[/eluser]
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.


HMVC: Base.php vs. Ci.php - El Forum - 06-24-2011

[eluser]Maarten Troonbeeckx[/eluser]
Now I get it, excellent Wink
Also answers my question on how to switch from multiple controllers to separation only.

Tnx, M.


HMVC: Base.php vs. Ci.php - El Forum - 06-24-2011

[eluser]Lotti[/eluser]
[quote author="wiredesignz" date="1308964018"]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]

hi! i've just installed your HMVC plugin and i'm trying to convert my app to work with it.

actually i need to extend MY_Controller (don't need HMVC functionality, just module separation). how to do this? it's possible?

thank you!


HMVC: Base.php vs. Ci.php - El Forum - 06-24-2011

[eluser]wiredesignz[/eluser]
Non HMVC application, MY_Controller extends CI_Controller.


HMVC: Base.php vs. Ci.php - El Forum - 06-25-2011

[eluser]Lotti[/eluser]
yes, i know that my_ extends ci_. the problem is that it says "cannot find my_controller". my_controller is inside application/core.

am i missing something?


HMVC: Base.php vs. Ci.php - El Forum - 06-25-2011

[eluser]InsiteFX[/eluser]
Did you save it as MY_Controller ?

InsiteFX


HMVC: Base.php vs. Ci.php - El Forum - 06-25-2011

[eluser]Lotti[/eluser]
yes. i can successfully extend it with a normal codeigniter controller (inside application/controllers)


HMVC: Base.php vs. Ci.php - El Forum - 06-25-2011

[eluser]Lotti[/eluser]
oh crap :\ i didn't copy the file inside application/core directory :\ i'm so sorry :\ everything works. thank you for the support


HMVC: Base.php vs. Ci.php - El Forum - 06-25-2011

[eluser]Maarten Troonbeeckx[/eluser]
@wiredesignz

Still missing something...
Are these statements correct?

HMVC:
- Structure controllers/views/models in separate modules
- Extend MX_Controller
- Make calls to multiple controllers using Modules::run()

Separation:
- Structure controllers/views/models in separate modules
- Extend CI_Controller as you would normally
- Calls to multiple controllers disabled

Beacause when all of my controllers extend CI_Controller, calls to Modules::run() work exactly the same as when I extend from MX_Controller...
I expected them NOT to work.

I'm confused now :/
Any thoughts on this?

Grtz, M.