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

[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.
#2

[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.
#3

[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.
#4

[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!
#5

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

[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?
#7

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

InsiteFX
#8

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

[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
#10

[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.




Theme © iAndrew 2016 - Forum software by © MyBB