title: How to Extend Controller Class in HMVC Module in Codeigniter to allow for Routing
body: <p><H2>Question:</H2></p>
  
  <p><strong>How do I extend a controller of an HMVC module and then call that extended class in Codeigniter's URI Router?</strong></p>
  
  <p><H2>Details:</H2></p>
  
  <p>Assuming the following typical Codeigniter file structure as it relates to HMVC:</p>
  
  <pre><code>/
  /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
  </code></pre>
  
  <p>I have a class <code>Events</code> stored in <code>/application/modules/events/controllers/events.php</code>.  I would like to extend it to <code>Courses</code> and <code>Conferences</code> which would provide specific functionality to those respective controllers.  I would like to store those controllers in the same module folder (ie. <code>/applications/modules/events/controllers/courses.php</code>, etc.)  I would like to route users that visit <a href="http://www.example.com/courses" rel="nofollow">http://www.example.com/courses</a> to the <code>courses</code> controller like so:</p>
  
  <pre><code>$route['courses'] = 'courses/getList';
  </code></pre>
  
  <p>I would also like to route users that visit <a href="http://www.example.com/conferences" rel="nofollow">http://www.example.com/conferences</a> to the <code>conferences</code> controller like so:</p>
  
  <pre><code>$route['conferences'] = 'conferences/getList';
  </code></pre>
  
  <h2>The Problem:</h2>
  
  <p>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 <code>course</code> class file at the following file path: <code>/applications/modules/courses/controllers/courses.php</code>. I have tried move that file to the aforementioned path, but I am then asked for the location of the <code>Events</code> controller class that <code>Courses</code> extends from.</p>
  
  <h2>A Possible Solution:</h2>
  
  <p>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 <code>/applications/modules/courses/controllers/courses.php</code> to be accessed.  This leaves me out of luck when trying to later route to the <code>conferences</code> controller.</p>