1
The scenario is this: I have a website that can be accessed by 5 different countries -> br.meusite.com
, us.meusite.com
, fr.meusite.com
, ... .
All Urls direct to the same folder within the server -> www/meusite
.
Each country has its own database: br_bancodd
, us_bancodd
, fr_bancodd
, ... .
In short, each country has its own database, but all countries share the same root folder files www/meusite
.
When the user accesses www.br.meusite.com
, transactions shall be made in the brbancodd
, So on. Every country with its bank.
Actualmete the system is in operation and to carry out this task of directing we use rewrite rules
with url amigaveis
to recover the URL that requested the access. Then we recover only the first 2 characters of the URL that will be br
or us
or fr
, ... and from there we have a file config.ini
which stores the access information to the database for each country, such as DB_CONNECTION(mysql),DB_HOST, DB_NAME, DB_USERNAME, DB_PASSWORD
, among others, and arrow the environment to perform transactions with the relevant data bank, until the user finishes the session.
I’m trying to pass this project to the Port and I’m having difficulties in this process of recovering the first two characters and directing to the respective database.
And how, in Laravel 5, the database access credentials should be recorded in .env
or config/database.php
, I do not understand how to record more information from different databases in this scenario, because it only fits information from a single database, or at most 2 (one in . env and another in config/database.php).
Surely there must be some way to allow access to many databases in Laravel 5. Someone has some idea?
In the case of this connection: $tabUser = DB::Connection('us')->table('usertable')->get(); Return $tabUser; would be called where? in models??
– R M