switching the --env option for artisan command on fly

Hi Devs,

I'm trying to pass --env option to the migrate command with the env file which i'm creating just before running the migration like here is the sequence,

Note: the commands are running from the code using the Artisan facade in the same request.

  1. I'm creating the env file with a name .env.migration using file_put_content('.env.migration').
  2. then next a Artisan command using Artisan:call('migrate', ['--env' => 'migration']).

but, it is referring to the variables from the .env files

please, suggest me what is right, Thank you.

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us