You could do something similar to this in your task:
class MyTask extends sfBaseTask
{
protected function configure()
{
$file = sfConfig::get("sf_config_dir") . DIRECTORY_SEPARATOR . "environment.cfg";
$env = (file_exists($file) ? file_get_contents($file) : "prod");
$this->addOptions(array(
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', $env),
}
}
The above should work; it works by default in the "prod" environment if the environment.cfg file does not exist. This also assumes that you only have the environment in the file (for example, "prod", "dev", "slappythefish", etc.).
source
share