How to load a library from Module using codeigniter modular extensions - codeigniter

i need to load a library from my module using Modular Extensions
my structure like this
modules/
modules/categories/library
categories_class.php
modules/categories/controllers/
categories.php
I need to load categories library in categories controller .
any one cane help me?

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.

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)

Related

is it important to use the same directories for views and models

is it important to use the same directories for views controllers and models or you can be free to create files inside created folders and refer to them when needed
in Laravel MVC
Check docs Directory Structure
The default Laravel application structure is intended to provide a great starting point for both large and small applications. But you are free to organize your application however you like. Laravel imposes almost no restrictions on where any given class is located - as long as Composer can autoload the class.
I myself haven't tried doing my own folder structure. I would personally stick with the standard created by Laravel and follow that.

What is preferred code/directory structure for extended modules?

What is equivalent of Rails /lib directory in Phoenix? and how code should be structured there?
From What goes in Rails lib/:
The generated Rails README proclaims:
lib — Application specific libraries. Basically, any kind of custom
code that doesn’t belong under controllers, models, or helpers. This
directory is in the load path.
The Rails guide says:
app/ Contains the controllers, models, views, helpers, mailers and
assets for your application.
lib/ Extended modules for your application.
In other words, app/ is
for “configuring Rails”, and lib/ is code that would make sense even
if your application was ported to the console or an Android app for
instance.
The equivalent directory in phoenix would be: your_app/lib/your_app.
and how code should be structured there?
All modules defined in a mix project's /lib directory are available in any other file in your project as ModuleName.func_name(). Phoenix in Action puts the public interface for your app in your_app/lib/your_app.ex with the rest of the files in the directory your_app/lib/your_app/.
Code should be structured like any other Elixir application.
Quote taken from Phoenix Framework docs Adding Page section.
Our lib/hello_web directory contains web-related files – routers, controllers, templates, channels, etc. The rest of our greater Elixir application lives inside lib/hello, and you structure code here like any other Elixir application.

base controller zend framework 2

I wonder if someone here can help, I am just starting with Zend Framework 2 and I am find it slightly daunting to get a project started off properly..
I am trying to create a base controller that I can be extended from. I am currently using the Zend Framework 2 skeleton application.
I have created a Resources folder in vendor/zendframework/zendframework/library. Within the the Resources folder, I have a Controllers folder which houses a BaseController.php file.
How do I get my project to autoload the BaseController in the Resources folder for it to be available through out the entire site?
Any help will be most appreciated.
Thanks
You shouldn't need to create a base controller, ZF2 already provides a number of base controllers for you, such as the RestController and the AbstractActionController
http://framework.zend.com/manual/2.0/en/modules/zend.mvc.controllers.html
If you are going to create a base controller, create you own module and put it in the vendors directory.
You should never need to go into third party modules and modify code as you should be able to inherit and extend the classes that are provided by such libraries

How to add custom code to the 'system' folder of CodeIgniter?

I am looking into building my own CMS / extended framework on top of CodeIgniter, and I was wondering how to structure it to keep code out of the application folder. I noticed that in a typical CI set up, the file structure looks like this:
application/ //code for your application
system/ //CodeIgniter core
index.php
However, in PyroCMS, They have used the following structure:
application/ //code for your application
system/
--cms/ //PyroCMS core
--codeigniter/ //CodeIgniter core.
How do I accomplish a similar result?
To emulate that structure just edit the index.php constants:
APPPATH
BASEPATH
#WebweaverD has provide you a good solution to improve your application usgin HMVC. I will give you another.
How about something like this:
-system/ //CI core
-index.php //manage the front_end requests
-acp.php //manage the back_end requests
-apps/ //applications dir
--back_end/ //only "admin" controllers, libraries, config. No views here
--frond_end/ //only "user" controllers, libraries, config. No views here
--acp/ //views for back_end
--themes/ //views for front_end
All above can be implemented as you want only extending the necessary core files.
The short answer is that everything starts from index.php, this is where core/CodeIgniter.php is included and it is also where application and system paths are set (retrieving values from config).
I think that pyro cms actually sets /system/cms as the application folder, presumably they have written code which looks at the presented application folder for content and processes it.
Another approach is to use wiredesigns modular HMVC:
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
This will allow you to separate your code out into modules. Just have a folder called cms containing all your cms modules and another folder to build your custom content on top.
You set the path to your modules folder in the config so if you wanted your cms code in the system folder you could set the path to your modules folder there and build on top using codeigniter in the standard way, perhaps adding a hook before or after your controller is loaded to call the cms core.
Mine is just a suggestion but you can easy fork pyrocms and build your own cms on it.
PyroCMS will deprecate codeigniter in the next version so you can keep their code and fix it where you need and modify it as you want

Joomla Save Module As Another Copy

I'm using Joomla 2.5.3.
I have this module that incorporates with authentication. For some reasons I want this module to be duplicated, so I save it as another copy.
Now, as its Module Type is same as the original one,say Auth, how do I customize the files of the copied module?
There is no folder for the copied module inside modules. Only the original one is there.
Thanks.
It depends on what you want to modify and how the module was created.
If the module was created using the MVC design pattern you want to modify ONLY the view (layout, html, css, js), then you'll need to check if the module supports multiple views/layouts or override the layout and create a view for each module depending on its Id. http://www.minitek.gr/tutorials/joomla-16-tutorials/item/21-how-to-create-a-new-custom-module-in-joomla-16.html
If the module wasn't created using the MVC design pattern, you could duplicate the module folder with another name and modify the name of the module in the xml, however it also depends on what the module does (does it write anything to the db?).
Maybe the easiest (probably not the best), would be modifying the current module depending on the module id. Check this out: http://docs.joomla.org/JModuleHelper/getModule
Think of a module as being similar to a class. You have one instance of the module created already. When you either clone the current instance or create a new instance there is still only one underlying set of files.
Each instance of the module contains its own individual settings so they should not clash with each other.
I can't think of any reason why you would need to customise the underlying files. If you do find a need then your best bet is to copy all of the files from the original module and use them as a base to build your own - entirely new - module, with a new name, new class names, etc.

Resources