[coldbox:15274] [ColdBox 3.5.1] Saas application

Settings are application-wide so you can’t just ovcanide them for one user. You can create a wrapper around getsetting that does its own “override” and returns a user specific

That’s pretty much what I do.

Log the user in, store their details in the cache, then onRequestCapture sticks that user object into the request context - which I can then access from anywhere in my app (models, handlers, plugins etc). I use a wrapper like Brad suggested, so if the cache object key doesn’t exist it falls back on a default setting struct in Coldbox.cfc.

@Mike: probably you are right! I should not create much more database. But I need some deep customization, for example the app is very wide and not all the features are available to all users.

@Tom thanks for the suggestion. Probably is the best choice.

I could use module for each feature? How can I set different modules for each user? I’ve never used modules and don’t know if this could be a good choice, to cut the app in too many pieces.

@phil how can i override database setting for each user?

hi there,

Jumping in late here.

I’ve seen it done by simply having each website hit it’s own wwwroot directory

Within that directory you can have an application.cfc that will define the requisite datasources, client IDs etc. that are needed to look up configuration settings.
You can reference some sort of bootstrap code for this, so that all wwwroot’s use common code.
Then the bootstrap code can call off to your common code base.

so a request hits something like this:
/clientdirectory/wwwroot/application.cfc <- extends BootstrapApplication.cfc
the local app.cfc can either override or call the Bootstrap requestStart functions etc.

there are other ways of doing it - and possibly better - however with this solution you can segment off each clients static resources into their own wwwroot directory, have sensitive files stored outside their webroot (but inside their client folder), you can use your web server to limit (or not) access to the client folder, etc. etc. etc.

Good luck. Maintaining a very large, very popular SaaS offering if rewarding but often crazy. Make sure you get this setup sorted upfront, keeping in mind how you will roll out product-wide updates seamlessly.


@Steve So I should set manually each application.cfc and create manually each webroot (subdomain)…

It certainly is one way of doing it.

Of course you can sniff host headers etc. to accomplish the same thing with a single webroot.

It depends on a few things, including whether you want the static file demarcation. In my previous life this was a good thing ™ as it allowed us to purge old clients easily.