gecche / laravel-multidomain

A Laravel extension for using a laravel application on a multi domain setting
MIT License
851 stars 107 forks source link

Created command don't see .env file #99

Closed dynabe closed 1 year ago

dynabe commented 1 year ago

After configuring the package exactly as it says in the instructions, I noticed that inside the invoked command laravel cannot connect to the database. Using Model or DB it returns an error: Access denied for user 'forge'@'localhost' (where 'forge' is the defult value in config/database)

dynabe commented 1 year ago

On the production server it works correctly and env() values are available, but on the local configuration it still does not work.

dynabe commented 1 year ago

Okey i found solution on local setup. Console commands can't recognize domain name, so I must add local domain name in bootstrap/app.php

$domainParams = [
    'domain_detection_function_web' => function() {
        return \Illuminate\Support\Arr::get($_SERVER,'HTTP_HOST') ?? 'local.test';
    }
];

$app = new Gecche\Multidomain\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__), dirname(__DIR__) . DIRECTORY_SEPARATOR . 'envs', $domainParams
);