title: Codeigniter HMVC from CLI: not entering controller
body: <p>I'm trying to run code from the CLI just as said in the CI documentation, but for some reason, maybe because of using the HMVC extension, it won't enter the specified controller.</p>
  
  <p>I have found no additional documentation about CLI execution in the HMVC extension site. </p>
  
  <p>Does anyone know how to deal with this?</p>
  
  <p>The code here:</p>
  
  <pre><code>/**
   * application/controllers/Cron.php
   * This is just a wrapper controller to use an HMVC module using the basic CLI syntax for CI
   *
   */
  class Cron extends MX_Controller
  {
  
      public function generatepdfs($start_date = null, $end_date = null)
      {       
              echo 'Not reached'; exit;
  
              $this-&gt;load-&gt;module('facturation/documentscontroller');
  
              $this-&gt;documentoscontroller-&gt;generatepdfs($start_date, $end_date);
      }
  }
  </code></pre>
  
  <p>No matter if I run this from the document root:</p>
  
  <pre><code>php index.php cron generatepdfs
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>/usr/bin/php -f /home/user/public_html/index.php cron generatepdfs
  </code></pre>
  
  <p>It will not display 'Not reached'.</p>
  
  <p>It does if I run it from the browser.</p>
  
  <p>These are some of the errors output to the console:</p>
  
  <p><strong>Unable to locate the specified class: Session.php</strong></p>
  
  <p>I have an overriden Session library MY_Session in application/libraries/session/MY_Session.php that works perfectly in a browser. If I move this file one directory upwards this error won't display again in the console, but it won't work in the browser. It is autoloaded by the way.</p>
  
  <p>A workaround for this I don't like at all: copy the same file in both locations.</p>
  
  <p>Next error: </p>
  
  <p><strong>PHP Fatal error:  Class 'CI_Preferencias' not found in /home/mysite/public_html/system/core/Common.php on line 196</strong></p>
  
  <p>I have a custom library called Preferencias, which is also autoloaded, in application/libraries/Preferencias.php</p>
  
  <p>Again, this works perfectly in the browser. However, from CLI it seems to search for a CI_Preferencias library, which doesn't exist. If I rename it to CI_Preferencias, and autoload "CI_Preferencias", CI will search for a class called CI_CI_Preferencias from CLI.</p>
  
  <p>I'm not sure if I'm missing something, or there's an actual bug in CI, or the HMVC module is messing with it.</p>
  
  <p>Could anyone help me?? This is getting me crazy since I must use CLI actions scheduled from cronjobs and I feel completely lost.</p>