Ahmed
Ahmed

Reputation: 556

How to load a library from Module using codeigniter modular extensions

i need to load a library from my module using Modular Extensions

my structure like this

modules/

modules/categories/library

modules/categories/controllers/

any one cane help me?

Upvotes: 1

Views: 8626

Answers (2)

Imran Nababan
Imran Nababan

Reputation: 99

I have another perspective for this error behavior, that make me spend about 3 hours, actually I am always using combination of Uppercase and Lowercase on my custom libraries on Codeigniter.

For wiredesigz of Codeigniter HMVC, remember the libraries loader behavior as same as CI itself, always use lowercase of your library classes name instead of actual class name (Maybe combination of uppercase and lowercase)

Upvotes: 0

NDBoost
NDBoost

Reputation: 10634

I see two problems..

Problem 1

According to your question, your categories module is not organized properly. The whole purpose of HMVC is compartmentalizing of code e.x; modules. Given your present question how does that structure allow you to copy your modules folder and paste it into another app? Answer: It doesnt..

Follow the example below

It should be the following from the app root:

/application/
   config
   modules/
    categories/
      views
      controllers/
        categories.php
      libraries/
        categories_class.php
      models
   libraries
   core
   controllers

Problem 2

per the user guide: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home

You must prefix the module name in front of anything referenced inside the modules folder.

e.g: $this->load->library('module/library');

or in your case: $this->load->library('categories/categories_class');

I have attempted previously to exclude the modules folder name and have never gotten it to work.

Controllers can be loaded as class variables of other controllers using $this->load->module(’module/controller’); or simply $this->load->module(’module’); if the controller name matches the module name.

Any loaded module controller can then be used like a library, ie: $this->controller->method(), but it has access to its own models and libraries independently from the caller.

Upvotes: 7

Related Questions