Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC version 5.2
#51

[eluser]a&w[/eluser]
I'm not comfortable enough to change the wiki so I'll just post my suggestions:

I think 7 should be changed from:

Quote:7) Move controller application/welcome.php to
application/modules/welcome/controllers/welcome.php.
to

Quote:7) Move controller application/controllers/welcome.php to
application/modules/welcome/controllers/welcome.php.

Maybe add a note to the wiki or add a config (as Matchbox does) like so:

Quote:The modules folder can be moved where you want by altering the following:
Code:
// file: application/libraries/MY_Router.php

/* define the modules base path */
//define('MODBASE', APPPATH.'/modules/'); // system/application/modules/
define('MODBASE', APPPATH.'../modules/'); // system/modules
#52

[eluser]wiredesignz[/eluser]
Typo corrected. Thanks a&w Wink

Let me think about the idea of altering MODBASE for a while, before I commit it to the wiki.
#53

[eluser]a&w[/eluser]
Thanks for continuing updates/additions to the wiki, it helps.

Any suggestions on where I should look for problems on this:

In matchbox:
I load file:
Code:
modules/someClass/libraries/SomeClass.php
from this file:
Code:
application/libraries/SomeLibrary.php
using:
Code:
$this->CI->load->module_library('status','status');

In ME:
I am trying to load file (same as above):
Code:
modules/someClass/libraries/SomeClass.php
from this file (same as above):
Code:
application/libraries/SomeLibrary.php
using:
Code:
$this->CI->load->library('status');

but I get:
Quote:An Error Was Encountered
Unable to load the requested class: status
#54

[eluser]wiredesignz[/eluser]
Just like I explained to codex in the other thread, Using ME requires thinking about organization of your application files.

A library should not use CI to load another library, if this library is dependent on another then `include` the dependency.

ME begins to offer a lot more freedom when used properly, and I made it follow some rules to keep it fast.

Anything located in the original application directories is considered a shared file, ie: available to all modules.

EDIT:
A point to note: CI has no reference to modules, so using $CI = get_instance() will always refer $CI back to the original application structure.
#55

[eluser]a&w[/eluser]
I'll have a look in the other thread for more info then. Might make sense to add that discussion to the wiki as a FAQ before the thought gets buried pages back?!

I have stepped through the code and I see where ME is currently assigning the defaultController as $this->_module (so it's looking for the library in
modules/defaultController/libraries/

I see it's getting defaultController from:

Code:
/** Set the module directory **/
    public static function path()
    {
//{{{
        $test1 = self::$home;
        $test2 = router::$_path;
//}}}
        (self::$home) OR self::$home = router::$_path;

        return self::$home;
    }
My OOP isn't up to snuff, I added $test to see if I could understand that following line.

I obviously need to see what you're talking about the other thread. But from a portability or ease of transition from 'standard CI ways' I still would wonder if there might be a minor adjustment made somewhere so it would know where to look for the module. I don't know matchbox that well(either) but it looks like it works with:
Code:
->load->module_library($module, $library = '', $params = null)
#56

[eluser]wiredesignz[/eluser]
Try using: $this->$CI->load->library('status/status'); the module prefix segment may work.
#57

[eluser]a&w[/eluser]
Looking over what you were saying in the other thread I'm still ... unresolved.

At this point I'm not talking about model, view, or controller. I'm talking about an library stored in application/library that is autoloaded from application/config/autoload.php library autoload setting. This autoloaded library is then trying to call someModule/libraries/someClass.

I think I'm with you on putting things in specific spots and including dependencies, but, it seems like I should be able (like Matchbox) to somehow load a module library in this context, no?
#58

[eluser]wiredesignz[/eluser]
No I disagree, the module and its files should be independent. ie: Not available outside the module, the module controllers are the entry points for the module. Matchbox was originally named Modular Seperation and by allowing you to cross load files it ruins that definition of seperation.

Shared libraries (available to all) should be located in application libraries.

MVC is all about seperation of concerns (jobs/tasks), Not how to write spaghetti OOP.
#59

[eluser]a&w[/eluser]
As previously mentioned, my OOP isn't up to snuff.

Code:
$this->$CI->load->library(’status/status’); the module prefix segment may work
That bit does appear to have loaded it ok. I'm not "happy" yet though because I feel like I'm hacking my way through this a bit and not embracing the philosophy of the preferred/efficient way of doing this.

Some examples of common/expected/preferable usage might be quite helpful in the wiki. For example:


Code:
L application1
   L libraries
      L mySharedApp1Library
   L modules
      L module1
      ...
      L module4
         L models
         L views
         L controllers
         L libraries
            module4Class1
            module4Class2
Example 1: mySharedApp1Library wants to use module4/libraries/module4Class2
Option 1:
Code:
//from inside mySharedLibrary:
$this->$CI->load->library(’status/status’);
I think you're saying there would be a better way to organize the above.

The way I'm thinking about it is more like this:
Code:
L system (CI Core goes here)
   L libraries (CI Core libraries)
L application1
   L libraries
      L mySharedApp1Library
L application2
   L libraries
      L mySharedApp2Library
L modules
   L module1
   ...
   L module4
      L models
      L views
      L controllers
      L libraries
         module4Class1
         module4Class2
Example 2A: as above, mySharedApp1Library wants to use module4/libraries/module4Class2
Example 2B: module4Class1 would be shared between App1 and App2
#60

[eluser]a&w[/eluser]
[quote author="wiredesignz" date="1215754205"]the module and its files should be independent. [/quote]
Agree.
[quote author="wiredesignz" date="1215754205"]
ie: Not available outside the module,
[/quote]
Really? Isn't part of the point of this that we should be able to use modules like lego blocks, building things by combining modules if we wanted to? Module A can't talk to Module B?
[quote author="wiredesignz" date="1215754205"]
the module controllers are the entry points for the module.
[/quote]
Hmmm. This is where I have to let it soak in I think. So inside the controllers we should be doing require_once?
[quote author="wiredesignz" date="1215754205"]
Shared libraries (available to all) should be located in application libraries.
[/quote]
By available to all, can that be extended as I have shown above, so it does NOT just mean "available to all modules within the application"




Theme © iAndrew 2016 - Forum software by © MyBB