Answer the question
In order to leave comments, you need to log in
Laravel. Different DB users for web application and migration, is it possible?
How in Laravel5 you can make different database users for a Web application and for migrations.
I would like to get by with the same .env file.
Well, this case is also of interest:
different database users on that part of the WEB application that is available to all visitors and on the part that is administrative.
Well, for example, it is clear that the visitor cannot delete products or other users, which means that the user's database privileges on these tables can be turned off.
I would not really like to arrange a pandemonium with configs for the database at the route level.
Answer the question
In order to leave comments, you need to log in
As a result, everything was resolved quite simply, in bootstrap/app.php I added:
if($app->runningInConsole()) {
$app->loadEnvironmentFrom('console.env');
} else {
if(Illuminate\Http\Request::capture()->segment(1) == 'admin_url' ){
$app->loadEnvironmentFrom('web_admin.env');
} else {
$app->loadEnvironmentFrom('web_client.env');
}
}
in env file after:
DB_HOST=localhost
DB_DATABASE=db
DB_USERNAME=name
DB_PASSWORD=pass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question