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 recognizing problem #98

Closed ozmouzer closed 1 year ago

ozmouzer commented 1 year ago

Hello, i have a problem with .env file

I'm need 2 databases on 2 domains - main domain.com and subdomain es.domain.com. I'm make domains with 'artisan domain: add' command, and create second sqlite connection in database.php, then change value of my env file. My problem with subdomain env file, when i'm change env.es.domain.com it's does not react, but when i'm edit env.domain.com it's applied to subdomain and domain too. Can you help me?

P.S. php artisan domain:list shows correct path to the env.es.domain.com ( - Env file: C:\OSPanel\domains\laravel\example-app/envs\.env.es.domain.com)

My laravel is 8.83.27 and Multidomain is 4.0 local OpenServer used

gecche commented 1 year ago

hi,

i'm off until next wedsneday and i cannot open any code, but the suspect is that the second domain is not well configured in some way, so the second env file is not recognized at all. i would need some more detail about your configuration, but the strange thing that I notice is the "envs" directory in your path. have you tried to put the second .env in the root project folder?

giacomo

ozmouzer commented 1 year ago

Thanks you for the answer!

Initialy i create envs in the root folder, but it doesn't work too. After i'm trying to relocate envs to envs foldier according to your documentation.

I'm tried return env back, but it still dosen't work

My bootstrap./app.php now:

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

I'm configure domain on local machine, making entry on windows hosts file: 127.0.0.1 es.domain.com and apply 'artisan domain: add' command. I'm use OpenServer 5.4.3 with Apache 2.4 and php 7.3. Database is sqlite

What else details i can provide?

ozmouzer commented 1 year ago

hi,

i'm off until next wedsneday and i cannot open any code, but the suspect is that the second domain is not well configured in some way, so the second env file is not recognized at all. i would need some more detail about your configuration, but the strange thing that I notice is the "envs" directory in your path. have you tried to put the second .env in the root project folder?

giacomo

Hi, can you help with this issue, it's still actual

gecche commented 1 year ago

Yep, I'm sorry... I completely forgot the issue. However, If you followed the installation instructions (and I think so), probably the problem is due to your specific server configuration. The only idea I had is the domain detection method: currently the package uses the SERVER_NAME server variable.

Could you check if that 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"

Let me know and excuse me for the delay

Giacomo

ozmouzer commented 1 year ago

Yes, It Is! Thank you very much!!!