Multi Tenant Backend (one codebase with multiple db)

Hi @daft and Everybody. I’m about to make OCMS backend multi tenant. I know there are multi tenancy laravel packages but I don’t need one more dependency. October has custom storage paths, custom file upload widget and so on… so even with those packages I would have to handle a lot of things myself.

Below is my check list to do. Do you know any other aspect which I have to take consideration? Thanks is advance for you answer.

  • Create a Middleware to switch tenant, connecting to correct db per tenant based on request’s host (subdomain or domain)

  • Store sessions in db instead of files

  • Separate file uploads per tenant (storage/app/uploads)

  • Separate uploaded media files per tenant (storage/app/media)

  • Separate cache per tenant (storage/framework/cache)

  • Separate logs per tenant (storage/logs)

  • Handle migrations per tenant

  • Handle scheduled jobs, console commands and queue jobs per tenant

Hi @danielbidala,

With everything you’re planning (separate DB, storage, media, cache, logs, jobs, etc.), at that point wouldn’t it be easier to just go with split installations? It might save you from having to maintain so many tenant-specific overrides inside a single codebase.

Many years ago I created plugin for exactly this.
I’m not sure it will not work with v4 (originally plugin was created for v1.1, and later updated for v2), but you can check it anyway.

Hello,

I would be excited by these features. What is the ETA of your work ? Can it be tested ?

Thank you

Multi-site and multi tenancy are different concepts. The plugin from @ksv looks interesting.

For multitenancy, we recommend a file-based system to separate configurations. Otherwise, you end up with two databases: one for tenant management and one for tenant data.

For better performance, a file-based solution is needed. Many moons ago, we had a basic configuration tool that generated specific configuration files for each tenant based on the Virtual Host configuration in Apache.

This somewhat falls outside the scope of October CMS and is more in the realm of DevOps.