gecche / laravel-multidomain

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

Job won't open the correct .env-file in Job? #84

Closed christoph-werker closed 1 year ago

christoph-werker commented 2 years ago

Dear Community,

i'am dispatching a Job like this and in my job i want to Send an API-Request.

Job::dispatch($user)->delay(now()->addMinutes(60*3));

For the Request i need the Keys from the correct ENV file. But unfortunately the Job open the .env and not the .env.domain

$this->api = new Api(env('API_KEY'), env('API_DOMAIN'));
$this->api->action($this->var);

My Scheduler works with php artisan schedule:run --domain=domain

I hope that you understand my Question and know a solution.

gecche commented 2 years ago

Hi,

but from which domain you dispatch the job? I ask you because to my knowledge there is no way to run a command/job under a certain domain/environment if you launch it from within the Laravel script ran under another domain/environment.

Cheers

Giacomo

christoph-werker commented 1 year ago

Sorry for the delayed reply.

Then you pushed the job under the domain: DOMAIN_A, will the server execute the job with the .ENV from DOMAIN_A?

gecche commented 1 year ago

yes... to my knowledge there is no way to "change the environment" from within the application itself. There is the need of some "machinery" outside the application which dispatch the jobs among the domains.

I think that in some way this is similar to another issue #14 which also could be solved only using a proper shell script.

I hope this helps... I close the issue for now... be free to reopen if you need

Cheers

Giacomo