We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Sub Folders in controllers

Is it possible to have sub-folders in the controllers folder?

Rather than have

controllers/ReportsController.php with actions:

public function fooAction(){ }

public functionbarAction(){ }

Can I use;

controllers/reports/fooController.php controllers/reports/barController.php

I just can't get that to work - maybe because it's not possible. I've used something similar in Code Igniter though.



98.9k

Controllers are loaded from the directories registered in the loader:

<?php

$loader = new \Phalcon\Loader();

$loader->registerDirs(
    array(
        '../app/controllers/'
        '../app/controllers/reports/'
    )
)->register();