[coldbox:6340] Re: Coldbox Multi-Application Architecture

If you are looking for different applications to run under the same framework. Then there is nothing that you need to do, just write the application as you normally would.

Modules are for sharing code that can plug into your application and could potentially be taken and plugged in some other site. That doesnt mean you cant use modules either, in fact i would encourage it.

Is there a way to use multiple config files (Coldbox.cfc,
Coldbox1.cfc ...) for different applications in single framework
skeleton?

@jeetu, Here is how we do it:

folder structure:

/core
    /coldbox
    /handlers - available to all
    /model - available to all
    /views - available to all
/site1
    /config - site specific
    /handlers - site specific
/site2
    /config - site specific
    /views - site specific

Notice that there is only one coldbox dir, but multiple config dirs.
The "magic" happens from your coldbox mappings and pointing your web
server to site1, site2, etc. Core is not a working site, it is just
the holder for everything that gets extended by the sub sites. If you
want a handler to act differently in one subsite, rewrite it and only
that site uses that handler.

You can do this, by switching at the Application.cfc level, where you can switch the configuration object via the :

For example, you can load different ones according to the incoming sub domain,

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

I have tried this but this happens only at application load.

if one client wants to see an application in his browser. 2nd client
wants a different application in his browser
and
The application structure to be like this...

/site1 + site 2 in same framework skeleton
    /config - site specific
    -----------Coldbox1.cfc for site 1
    -----------Coldbox2.cfc for site 2
    /handlers
    -----------Handler1.cfc for site 1
    -----------Handler2.cfc for site 2
    /model
    -----------Model1 folder for site 1
    -----------Model2 folder for site 2
    /views
    -----------View1 folder for site 1
    -----------View 2 folder for site 2

How will this help?

Please see figure in the following link
http://jeetualex.blogspot.com/2010/10/multiple-configuration-settings-for.html

That is not true, when using the Application.cfc file there is this:

  COLDBOX_APP_KEY = "";

As this is in the pseudo constructor you could write your own function as
Luis said to modify this based on your URL.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of jeetu
Sent: Sunday, 24 October 2010 12:52 AM
To: ColdBox Platform
Subject: [coldbox:6348] Re: Coldbox Multi-Application Architecture

I have tried this but this happens only at application load.

if one client wants to see an application in his browser. 2nd client wants

a

different application in his browser and The application structure to be

like

Sorry that should have been

  COLDBOX_CONFIG_FILE = "";

Regards,
Andrew Scott
http://www.andyscott.id.au/

When you change the property COLDBOX_CONFIG_FILE and load Coldbox2.cfc
to load config settings of site2 it overrides the previously loaded
Coldbox1.cfc of site1. So if client1 is seeing site1 in his browser
and when client2 requests for site2 it overrides site1 and if client1
refreshes his browser page he will be seeing site2

If COLDBOX_CONFIG_FILE persisted in the session i think that would be
possible. not sure though :slight_smile:

Jeetu, I believe that is why you need to use the folder structure I
described above, so that you have separate application scopes.

I realize that you are simplifying the description, but i have to
ask: If *all* of this stuff is separated (handlers, model, views) why
are you trying to combine them? Why not just create two separate
sites? Is there code that overlaps? Can you explain the functional
requirements a little more?

Instead of 'Site' lets use the term 'Application'.
Say for example my site has 3 applications. all 3 are specifically
sharing in the model.

Site 1:

So it would never occur to you to use a different application.name for each
site?

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of jeetu
Sent: Sunday, 24 October 2010 1:34 AM
To: ColdBox Platform
Subject: [coldbox:6351] Re: Coldbox Multi-Application Architecture

When you change the property COLDBOX_CONFIG_FILE and load
Coldbox2.cfc to load config settings of site2 it overrides the previously

loaded

Coldbox1.cfc of site1. So if client1 is seeing site1 in his browser and

when

client2 requests for site2 it overrides site1 and if client1 refreshes his

browser

Yes the 3 applications are having 3 different appNames

coldbox = {
    appName = "[Product News | Investor News | Sports News]",
                ...
}
But only one Application.cfc Corresponding to 'News'
The 3 applications work independently except some models are shared.
Each application needs to be mapped as a URL with a separate
defaultEvent and other config file parameters.

This is why i proposed the 3 config objects instead of config files so
that every setting can be reused for different applications inside the
same framework skeleton and wont be overridden. The 3 config objects
stay in the same Application Scope as3 different entities used by 3
different applications

Instead of <cfset COLDBOX_CONFIG_FILE = ""> if we have <cfset
COLDBOX_CONFIG_OBJS = "Coldbox1, Coldbox2, Coldbox3">
where Coldbox1, Coldbox2 and Coldbox3 are instances of component
Coldbox.cfc
and we are able to load config settings of Application1 from Coldbox1
and same for 2 & 3.

Is Config object instance possible instead of config file?

No I meant the this.name (Application.Name) in the Application.cfc

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of jeetu
Sent: Sunday, 24 October 2010 2:07 PM
To: ColdBox Platform
Subject: [coldbox:6357] Re: Coldbox Multi-Application Architecture

Yes the 3 applications are having 3 different appNames

coldbox = {
    appName = "[Product News |
Investor News | Sports News]",
                ...
}
But only one Application.cfc Corresponding to 'News'
The 3 applications work independently except some models are shared.
Each application needs to be mapped as a URL with a separate defaultEvent
and other config file parameters.

This is why i proposed the 3 config objects instead of config files so

that every

this.name in Application.cfc will be "News" same for all 3
applications

Sorry but if you are using one core application code, with one name then how
is this a multi-application?

Regards,
Andrew Scott
http://www.andyscott.id.au/

What i am thinking is to instantiate 3 object instances of config
(Coldbox.cfc) ie, coldbox1, coldbox2 & coldbox3 in the single
Application.cfc (Application Scope) and use the 3 instances to load
their default controllers based on the URL.

All i want to do is to get 3 config objects in the single application
scope to control my 3 sub applications (Product News, Investor News
and Sport News) in the News Application framework skeleton. These
three are different business in the single framework.

News -- is the coldbox framework -- contains Application.cfc
(this.name = "News")
---Product News -- is Application 1 initiates from url /index.cfm?
event=Handler1.Init (coldbox1 appName="Product News")
---Investor News -- is Application 2 initiates from url /index.cfm?
event=Handler2.Init (coldbox2 appName="Investor News")
---Sports News -- is Application 3 initiates from url /index.cfm?
event=Handler3.Init (coldbox3 appName="Sports News")

Let me ask this then, why is it important to have 3 configs? The only thing
that I can see that will be different is settings for each app, the others
like caching, conventions etc should be the same.

If you can give me a clue as to why or what you want to achieve from the
config's I’ll show maybe a better way to approach it.

Give you an example, I have 5 sites running from one application, with one
config file and multiple ORM's and Event handlers.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of jeetu
Sent: Sunday, 24 October 2010 7:56 PM
To: ColdBox Platform
Subject: [coldbox:6364] Re: Coldbox Multi-Application Architecture

What i am thinking is to instantiate 3 object instances of config
(Coldbox.cfc) ie, coldbox1, coldbox2 & coldbox3 in the single

Application.cfc

(Application Scope) and use the 3 instances to load their default

controllers

based on the URL.

All i want to do is to get 3 config objects in the single application

scope to

Ok, I understand what you are trying to do now. But why you are not doing
this as modules is a mystery to me.

In your config.cfc you will need to do something like this.

//--------------------------------------------------------------------------

Please refer this link
http://jeetualex.blogspot.com/2010/10/multiple-configuration-settings-for.html
This is what i am trying to do.

With what you are suggesting is it possible to see "Sports News" and
"Product News" simultaneously in 2 browsers?
When you load "Sports News" from your environment it is overriding the
Coldbox properties in the application scope and Sports News is
displayed.
When you load "Product News" it again overrides the previously loaded
Sports News properties in the application scope and displays Products
News.

As coldbox.debugMode or any other property is one throughout the
application scope.

instead if you use
coldbox1.debugMode = true;
coldbox2.debugMode = true;
...
this will load different applications at the same time.

Please correct me if i am wrong :slight_smile: