I develop a software to plan and manage meetings in Schools. Everything is working fine so far but now I am at the point where I need to serve my laravel application to multiple schools without using the same database for security reasons.
Now I want to use different MySQL-Connections depending on which url the client comes from.
For example:
school1.example.org
uses DB1,school2.example.org
uses DB2 and so on.My backend should only be on one server with external Database servers. So maybe something like this:
How could I possibly realize that? Ideally that will scale automatically if new schools want to use this, but if there is manual work needed for deployment that will be okay at the beginning.
I hope that you understand what I need and can help me with that.
Best regards, Marvin
You can follow this approach and improve according to your requirements.
Create
Schools
table. In this, for each school, keep a record with the subdomain (unique identifier) and School DB connection information.
This would contain all tables for your app. Each school will have a separate DB.
config/database.php
.