The scenario is as follows: I have a web site that can be accessed by 5 different countries - > br.meusite.com
, us.meusite.com
, fr.meusite.com
, ....
All URLs point to the same folder inside the server - > www/meusite
.
Each country has its data base: br_bancodd
, us_bancodd
, fr_bancodd
, ....
In short, each country has its database, but all countries share the same files as the root folder www/meusite
.
When the user accesses www.br.meusite.com
, the transactions will be done in the brbancodd
database, and so on. each country with its bank.
Currently the system is up and running to do this targeting task we use rewrite rules
with url amigaveis
to retrieve the URL that requested the access. Then we retrieve only the first 2 characters of the URL which in this case will be br
or us
or fr
, ... and from there we have a config.ini
file that stores the database access information for each country, such as DB_CONNECTION(mysql),DB_HOST, DB_NAME, DB_USERNAME, DB_PASSWORD
, among others, and set the environment to perform transactions with the relevant database, until the user logs out.
I am trying to pass this project to laravel and I am having difficulties in this process of recovering the first two characters and heading to the respective database.
And because, in laravel 5, the database access credentials should be written to .env
or config/database.php
, I do not understand how to write more information from the different databases in this scenario, a single database, or at most 2 (one in .env and one in config / database.php).
Surely there must be some way to allow access to many databases in laravel 5. Does anyone have idea idea?