phalcon\loader - singular vs plural namespaces loading problem

I found a bug in a phalcon project I have been working on that was hard to troubleshoot because it happenns only in the testing environment (there are a few differences between the centos environments: may be phalcon versions or apache versions but I am assuming that they are not the reason). So the problem is that a file is not found, because of a missing "s" in the "Controller" namespace registration.

This is the file where the namespaces are registered (note the App\Front\Controller missing the "s" at the end)


        'App\Front\Controller'             => MODULES_PATH.'/front/controllers/',
        'App\Front\Model'                   => MODULES_PATH.'/front/models/',
        'App\Front\Validator'               => MODULES_PATH.'/front/validators/',
        'App\Front\Service'                 => MODULES_PATH.'/front/services/'

Then there is a file where, after loading the above one, meaning after having the loader registered, there is some dispatcher forwarding happening as below:


    "namespace" => "App\\Front\\Controllers",
    "controller"=> $this->getControllerName(),
    "action"    => $forwardAction

While this is one of the controllers that is being requested and is found/loaded/returned, except for in my testing machine.


namespace App\Front\Controllers;

class SomeController extends \Phalcon\Mvc\Controller {


So basically changing the first key in the registerNamespaces() method in File1 from 'App\Front\Controller' to 'App\Front\Controllers' in my development environment (the working scenario) does not make a difference at all. The controller class/file is loaded in both cases and php does not bark about file not being found. If I change "App\Front\Controllers" to "App\Front\Controller" in either File2 or File3, then all the references to that namespace must be in singular in all the three files otherwise it won't work.

So I am puzzled as to why this is happening? Is there some type of magical internal implementation in the registerNamespaces() method that checks for the plural of a word/noun as well (it's the only thing I can think of) or is there something else that I am not seeing?

p.s. Fixing my testing environment, required simply appending another "s" to the 'App\Front\Controller' in File1.

Well just to be noticed: you shouldnt forward in multimodule application to controller in another module imho. If you doing it you should consider changing something in your application logic.


You just need to keep them all the same. But, I still doubt why your development environment works ok with the wrong register?