Having more than one Controller / Model / View directories for different domains (or other reasons).

In CakePHP there is a feature where you can setup a hierarchy of directories for pretty much anything. It works by scanning each directory until it hits the file it needs based on the route. I'm toying with the idea of having one main app and harbouring custom code in the same place.



So say I have an application that covers mostly what clients want but some of the clients have requested a specific feature. Rather than duplicate the entire app and re-host it I would like to tell Phalcon use directory A and B for controllers (or whatever) does Phalcon have such a feature? I only seem to be able to find examples of creating a backend and a frontend.


U can do it with events, like in the INVO security.

I think if u create a beforeDispatch event, u can check if u have an extended controller for that project, and than u can forward the request to that controller :)

I hope it's help for u.

edited May '14

Well that does give me an option to help me make sure the app makes decisions but what I would like to be able to do is "include" the sub directory in as ALSO the controllers directory.

So, if I have the following:


I want to say: "Look in /controllers first and then /acme.example.com if you can't find it." So www.example.com/orders/myaction and acme.example.com/orders/myaction would both be the same but acme.example.com/acme/myaction would also work for that sub domain because once it didn't find the controller Phalcon moved on to the next folder it has registered. Currently I can only get Phalcon to accept one folder and that's that. I want to have in my config a routine that includes any folder with the same name as the url so all that needs to be done is to upload a folder and then version control on the core app is much easier. This could turn out to be a rubbish idea I realise but it's my first one.

In your bootstrap file I assume you have something like this:

$Loader = new \Phalcon\Loader();
// put code here

to load your controller directory?

Where I've written put code here you could add code to determine the current requested domain name, then dynamically add it as a directory. Something like (this is pseudo-code)

$domain_name = $_SERVER[‘DOMAIN’];