gecche / laravel-multidomain

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

.env.domain.com doesnt get loaded or read #104

Closed abbasmashaddy72 closed 10 months ago

abbasmashaddy72 commented 10 months ago

92

Same issue Hear @edwinsmasher Please reopen it again

gecche commented 10 months ago

Could you check if the SERVER_NAME server variable is instantiated in your execution environment? If not you can try to switch for example to HTTP_HOST, following the instructions in the docs in the section: "Customizing the detection of HTTP domains"

abbasmashaddy72 commented 10 months ago

Could you check if the SERVER_NAME server variable is instantiated in your execution environment? If not you can try to switch for example to HTTP_HOST, following the instructions in the docs in the section: "Customizing the detection of HTTP domains"

I have followed all the instructions but not working as excepted

below both code are not working

str_replace('{app_name}', env('APP_NAME'), - Showing No Data {{ config('app.name', 'Laravel') }} - Showing from env

when I delete env file showing 500 error

You can Check my repo: Repo Link

str_replace('{app_name}', env('APP_NAME') - HomePage Footer - Code in Helper {{ config('app.name', 'Laravel') }} - in layouts app & guest

gecche commented 10 months ago

Hi,

I have seen your repo, but, as pointed out in the "Customizing the detection of HTTP domains" section in the docs, could you try to put this snippet in the bootstrap/app.php file?

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

//$app = new Illuminate\Foundation\Application(
$app = new Gecche\Multidomain\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__), null, $domainParams
);
abbasmashaddy72 commented 10 months ago

Hi,

I have seen your repo, but, as pointed out in the "Customizing the detection of HTTP domains" section in the docs, could you try to put this snippet in the bootstrap/app.php file?

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

//$app = new Illuminate\Foundation\Application(
$app = new Gecche\Multidomain\Foundation\Application(
    $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__), null, $domainParams
);

Thanks, Brother, It is Working Now

few Doubts

  1. Will it work with https also
  2. Migration If change DB for Domain how to Migrate it. I tried php artisan migrate --seed --domain=medecare.test but was not able to migrate it migrates from .env not from .env.medecare.test
gecche commented 10 months ago

1 - Will it work with https also

Yes

2 - Migration If change DB for Domain how to Migrate it. I tried php artisan migrate --seed --domain=medecare.test but was not able to migrate it migrates from .env not from .env.medecare.test

All the laravel commands work with the domain option. However you can't use the --seed option because it launches another command internally without the domain option

Cheers

abbasmashaddy72 commented 10 months ago

Thanks Brother