[Solar-talk] Organizing multiple Solar applications

Andreas Ravnestad andreas.ravnestad at gmail.com
Sat Nov 11 16:23:25 PST 2006


Hi all, hope I'm not ruining your caturday :)

I'm in the process of converting some legacy apps to Solar, and I ran 
into some problems when I placed multiple "vendor" directories in a 
common root directory (I'm quoting "vendor" because in this context I'm 
thinking more of them like applications and not vendors).

The entry point for the applications is /index.php, and the "vendor" 
directories are structured as /Journal, /Meta, /Map and so on. The 
/index.php just starts solar, and in my solar.config.php file I have the 
following:

$config['Solar_Controller_Front']['classes'] = array(
    'Solar_App',
    'Journal_App',
    'Meta_App'
..and so on.

[ A side note: the corresponding directories (/Journal, /Map, etc) are 
locked down with a htaccess file to prevent snoopers from browsing around ]

But of course this only works as long as there are no identical 
controllers in the various application directories - and Solar will of 
course look up the first controller class that matches, ignoring the 
remaining controllers that might match. 

One solution to this is to add an entry point to each application 
directory and let them live their own lives completely. But there are a 
few problems with this. For example, for any given "vendor", I may want 
to be able to access a few classes in some other application (using 
Solar::loadClass()). This means that if the entry point is switched from 
/index.php to /Map/index.php, I'd have to modify the include path to 
include the parent directory, + a few other non-relevant hacks.

I hope you're not confused yet, it gets worse :)

So I decide that /index.php remains the entry point, because it 
determines which application (or "vendor") that should be used in a 
request based on the subdomain in the request anyways. But the problem 
with the duplicate controllers remain. So here's what I do:

In each application directory, I put a solar.config.php, with specific 
settings for that application (for example, /Map/solar.config.php). And 
in the entry point (/index.php), I simply include the proper config file 
when starting solar, based on the subdomain - and this works perfectly. 
I get full granularity on the classes, and I get the right include path 
without hacks.

Now my questions: is this a proper way to do it? Are there better ways 
to do this that you can think of? For example, should I completely 
isolate these applications and use virtual host configuration in apache 
to execute the proper applications?

-Andreas


More information about the solar-talk mailing list