I’m writing a Custom Laravel Command that bundles some artisan commands:
class MyCommand extends Command {
...
public function handle() {
//Call some php artisan commands...
$this->call('config:clear')
$this->call('migrate', [
'--env' => 'testing',
])
...
}
}
But I want to ensure it always runs using a specific .env file. But I found out that the ‘–env’ option get’s ignored inside the Command itself.
Is there a way to ‘load’ this specific ‘.env’ file?
I tried this, but it had no effect:
$testingEnv = DotenvDotenv::createImmutable(base_path(), '.env.testing');
$testingEnv->load();