Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)

[eluser]adamp1[/eluser]
I think there is a slight bug in the way models are loaded.

MY_loader.php in model()
Code:
if (CI_VERSION < 2)
{
    class_exists('Model', FALSE) OR load_class('Model', FALSE);
}
else
{
    class_exists('Model', FALSE) OR load_class('Model', 'core');
}

The issue is with the else. In CI 2.0 the Model class is always called CI_Model rather than Model in CI < 2.0. This means the class_exists always returns false and it always trys to reload the CI_Model class.

Shouldn't it be.

Code:
if (CI_VERSION < 2)
{
    class_exists('Model', FALSE) OR load_class('Model', FALSE);
}
else
{
    class_exists('CI_Model', FALSE) OR load_class('Model', 'core');
}

[eluser]wiredesignz[/eluser]
Modular Separation now runs on the same code base as Modular Extensions - HMVC and is available via my bitbucket repository.

http://bitbucket.org/wiredesignz/codeign...sions-hmvc

Check it out, to use Modular Separation only, simply do not include the MX/Controller file.

Feedback is appreciated.

[eluser]Unknown[/eluser]
Hello,

Thanks for the library. I tried to install as instructed in the Wiki and when I run the example (welcome controller) I got the following error:

Fatal error: Class 'MX_Config' not found in /home/sujini/kindlevn/system/application/third_party/MX/Base.php on line 73

Can you give me an advice? Thanks

[eluser]wiredesignz[/eluser]
The wiki is horribly out of date and not recommended for installing version 5.3

If you are installing on CI 1.7 then the application/core classes should be relocated to application/libraries.

If you do not require HMVC functionality then remove the "require" from application/libraries/MY_Controller.php or delete the file entirely.

[eluser]Daniel Cronin[/eluser]
Hello,

I was using HMVC 5.2, but I'm developing a new application and I'm confused. I don't understand the differences between Modular Separation (http://github.com/philsturgeon/codeignit...separation), HMVC 5.2 and HMVC 5.3.

I'm working on a really important application, so I really need to get this right. I was thinking of choosing HMVC 5.3.

The setup that I want to create will be structured like this...
application/
----modules/
--------module_name/
------------controllers/
----------------admin.php (extends Admin_Controller)
----------------model_name.php (extends Public_Controller)
------------views/
------------models/

Admin_Controller extends MX_Controller which extends Controller.

Any recommendations on which one would be the best choice for me?

Also, what does it mean when you say it is only using a single controller per request? How many controllers load per request with the default installation?

[quote author="wiredesignz" date="1249362628"]Hi Johan,

Modular Separation allows you to use modules for code organization in your application while only using a single controller per request. (no HMVC)

It works the same way as Zach's Matchbox, But is much faster in execution and does the job without using additional module_xxxx() calls.

Modules now comply with CI 1.7.2 also, Controllers in sub-directories are supported and resources may be cross loaded from other modules.

You should be able to take any CodeIgniter application and place it into a module and it should work without alteration. However routes might need altering to allow for the added separation of a module.[/quote]

Best regards,
Daniel

[eluser]wiredesignz[/eluser]
If your controllers extend the MX_Controller class then you have HMVC features available which allow you to load and use other controllers from other modules.

If your controllers extend the Controller class then you can use modular features but not HMVC so you have only a single controller.

[eluser]Daniel Cronin[/eluser]
[quote author="wiredesignz" date="1284697110"]If your controllers extend the MX_Controller class then you have HMVC features available which allow you to load and use other controllers from other modules.

If your controllers extend the Controller class then you can use modular features but not HMVC so you have only a single controller.[/quote]

Excellent! Thank you. That answers my question.

[eluser]Phil Sturgeon[/eluser]
Update 17/09/2010: Modular Separation has been merged into Modular Extensions.

Modular Extensions adds HMVC aspects to your modules which means you can load controllers from other controllers which Modular Separation did not support. To continue using modules in the same way as in Modular Separation simply do not use or include the MX/Controller or extend from MX_Controller, just use the old Controller in the same way.


Edit: Ha, that was meant to go into the Wiki, I use the forum to build my syntax then copy it over. Either way, you get the idea Smile

[eluser]Unknown[/eluser]
Thanks a lot!
it'working fine for me

[eluser]Twisted1919[/eluser]
Something is wrong or i do something wrong ?
I want to use HMVC features, so i dropped the files in core and third party as required , then
in core folder i have MY_Controller :
Code:
&lt;?php (defined('BASEPATH')) OR exit('No direct script access allowed');

require APPPATH."third_party/MX/Controller.php";

class MY_Controller extends MX_Controller{

        public function __construct()
    {
           parent::__construct();        
           $this->load->library('session');
        }
then i have my welcome controller which extends MY_Controller which extends MX_Controller which extends CI_Controller, as advised.
Now, i am trying to extend the session library, making a test function to see if it works so:
/application/third_party/MX/Session.php
Code:
exit('here');//should die if included, but it doesn't,why?
class MX_Session extends CI_Session{
    
    public function __construct()
    {
       parent::CI_Session();
    }
    
    function sess_update()
    {
       // skip the session update if this is an AJAX call!
       if ( ! IS_AJAX )
       {
           parent::sess_update();
       }
    }

     function sessionate()
    {
       return 'xyz';
    }

}
then i have /app/core/MY_Session.php
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
exit('11111');//this also should die also, but it doesn't
require APPPATH."third_party/MX/Session.php";

class MY_Session extends MX_Session{}
and finally the Welcome.php controller /app/modules/welcome/controllers/welcome.php
Code:
&lt;?php

class Welcome extends MY_Controller {

    function __construct()
    {
        parent::__construct();        
    }
    
    function index()
    {    
        //echo '<pre>';
        //var_dump($this->session);
        print_r($this->session->userdata); // is okay .
        echo $this->session->sessionate(); // not okay.
    }
}
returns : Fatal error: Call to undefined method CI_Session::sessionate() in C:\wamp\www\app\modules\welcome\controllers\welcome.php on line 15

So, what's wrong ?




Theme © iAndrew 2016 - Forum software by © MyBB