Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:43:33+00:00 2026-06-03T19:43:33+00:00

Question: How do I extend a controller of an HMVC module and then call

  • 0

Question:

How do I extend a controller of an HMVC module and then call that extended class in Codeigniter’s URI Router?

Details:

Assuming the following typical Codeigniter file structure as it relates to HMVC:

/
/application
/application/modules
/application/modules/module-name
/application/modules/module-name/controllers
/application/modules/module-name/controllers/controller-name.php
/application/modules/module-name/models
/application/modules/module-name/models/model-name.php
/application/modules/module-name/views
/application/modules/module-name/views/view-name.php
/application/config
/application/config/routes.php

I have a class Events stored in /application/modules/events/controllers/events.php. I would like to extend it to Courses and Conferences which would provide specific functionality to those respective controllers. I would like to store those controllers in the same module folder (ie. /applications/modules/events/controllers/courses.php, etc.) I would like to route users that visit http://www.example.com/courses to the courses controller like so:

$route['courses'] = 'courses/getList';

I would also like to route users that visit http://www.example.com/conferences to the conferences controller like so:

$route['conferences'] = 'conferences/getList';

The Problem:

Unfortunately, I can’t seem to get this working because courses isn’t contained in it’s own module and therefore can’t be found by the router. It appears that the router is looking for the course class file at the following file path: /applications/modules/courses/controllers/courses.php. I have tried move that file to the aforementioned path, but I am then asked for the location of the Events controller class that Courses extends from.

A Possible Solution:

One possible solution might be to contain each of the controllers in a single controller file. However, I do not wish to do this because I like to store each class in it’s own individual file and grouped with it’s extended classes if at all possible. I am looking for a more elegant and altogether correct solution. Even if I were to attempt this technique of a single file, it would need to be contained in /applications/modules/courses/controllers/courses.php to be accessed. This leaves me out of luck when trying to later route to the conferences controller.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:43:36+00:00Added an answer on June 3, 2026 at 7:43 pm

    It seems that by adding

    require APPPATH."modules/events/controllers/events.php";
    

    to the beginning of my extended classes (courses and conferences) I will be able to leave the Events module alone.

    Unfortunately, I have to create separate modules for the courses and conferences controllers. Oh well, I guess it can’t be perfect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CodeIgniter has a method $this->load->vars($array) that is ideally used in the parent Controller to
As per a previous question I'm setting up the HMVC extension for codeigniter. https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
Additional thanks extend to Daniel Newby for answering my memory usage question (and Martin
i am an android newbi. i extend my apologies for a very primitive question.
Question about subclassing in matlab, under the new class system. I've got class A
Question 1: Is is possible to throw an exception that will not be caught
Codeigniter has its own Models path, where models extend from CI_Model. I'm using RedBean
I'm writing a controller helper that sets the proper response headers for my REST
my first question is, where do I put this custom extension so that it
I have an abstract base Controller class and all action controllers are derived from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.