I have three dot env, default .env
for example.com
, .env.sub1
for sub1.example.com
and .env.queue2
for sub2.example.com
I am able to load different .env when I bootstrap using the following code in bootstrap/app.php
. This works really well when I access the websites.
$env = $app->detectEnvironment(function () {
$environmentPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
$environmentFile = null;
switch (getenv('HTTP_HOST')) {
case 'sub1.example.com':
$environmentFile = '.env.sub1';
break;
case 'sub2.example.com':
$environmentFile = '.env.sub2';
break;
}
if (!empty($environmentFile) && file_exists($environmentPath . $environmentFile)) {
Dotenv::load($environmentPath, $environmentFile);
} else {
// .env will be in affect, do nothing
}
});
This also works really well when your QUEUE_DRIVER
is set to sync
.
But the problem when my QUEUE_DRIVER
is set to beanstalkd
it take the environment variables always from .env
.
Where is beanstalkd queue loading the .env
while executing a queued job.
Thanks,
K
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire