/** * Get the environment from the --environment option * or from the CRAFT_ENVIRONMENT env variable * @return string|null */ protected function getEnvironmentOption() { $definition = new InputDefinition(); $definition->addOption(new InputOption('environment', null, InputOption::VALUE_REQUIRED)); $input = new Console\GlobalArgvInput(null, $definition); return $input->getOption('environment') ?: getenv('CRAFT_ENVIRONMENT'); }