Пример #1
0
 /**
  * @return mixed[]
  * @throws \Abacaphiliac\ZendPhpDotEnv\Exception\InvalidConstantPathException
  * @throws \Abacaphiliac\ZendPhpDotEnv\Exception\InvalidEnvironmentVariablePathException
  * @throws \Abacaphiliac\ZendPhpDotEnv\Exception\InvalidWorkingDirectoryPathException
  */
 public function loadEnvironmentVariables()
 {
     // Load from application-path defined by constant.
     if ($this->constant && defined($this->constant)) {
         return DotEnvLoader::loadFromConstant($this->constant, $this->file);
     }
     // Load from application-path defined by environment-variable.
     if ($this->variable && DotEnvLoader::hasEnvironmentVariable($this->variable)) {
         return DotEnvLoader::loadFromEnvironmentVariable($this->variable, $this->file);
     }
     // Load from working directory. ZF2 applications change the working directory to the application root.
     return DotEnvLoader::loadFromWorkingDirectory($this->file);
 }
Пример #2
0
 /**
  * @param string $name
  * @param string $file
  * @return Dotenv
  */
 public static function createFromEnvironmentVariable($name, $file)
 {
     $path = DotEnvLoader::getEnvironmentVariable($name);
     return self::create($path, $file);
 }