Multi modules registerClasses


I'm using multi modules structure and I can't register my external classes. Theses classes are located in Project/common/ext-lib/. So I put in my loader.php this :

$loader = new \Phalcon\Loader();

 * We're a registering a set of directories taken from the configuration file

        "Pdf"  => "../../common/ext-libs/Pdf.php",
        "Mail"      => "../../common/ext-libs/Mail.php",
        "Tools"     => "../../common/ext-libs/Tools.php",
        "EDpdf"     => "../../common/ext-libs/EDpdf.php"


And this loader.php is called in the bootstrap file.

But I have an error when I call, for example, Tools.php class by calling $tools = new Tools() and I don't know how I can fix that. This works well in my single application but it doesn't work in my multi module application.

PHP Fatal error: Class 'Apps\\Frontend\\Controllers\\Tools' not found

But is it working for example in after registering and not accesing module ? Is Tools in any namespace ? Are you sure path you provided is correct ? Also $config->application->controllersDir, I thought you have controllers in module ?

edited Apr '16

Yes it works, I can see my frontend and the second module rest api, but when I'm calling an external class as Tools, I have an error 500. All my external libs are not loaded.

Tools has a namespace Common\External.

$config->application->controllersDir is the path for the frontend controllers folder.

Maybe I have to change my project structure and put common folder under apps folder to get this :

├── apps
├── common
│   ├── config
│   ├── models
│   ├── external
├── public
edited Apr '16

And you have in your controller use Common\External\Tools, right ? If not then start using some IDE like netbeans or phpstorm.


Ok thanks. I used Common\External instead of Multiple\Common\External\Tools.

But can I make a project multi module without namespace ? Because I don't like to use namespace, I prefert to use register classes and register dirs because I don't have to set the namespace in all my controllers and class in this case... It's easier. But I don't find any examples of multi modules project without namespace.