Monday, May 22, 2017

Lumen does not read env from system during request

Lumen 5.4, MySql & Docker. I have following variables in global env

$ printenv
DB_HOST=127.0.0.1
DB_DATABASE=database
etc

.env in my project the are present also, but they have different values.

If I type in tinker env('DB_HOST'), it prints value from the global environment, but when application runs, it takes from the specified .env file. I think the problem exists within following function in Laravel\Lumen\Application :

/**
 * Load a configuration file into the application.
 *
 * @param  string  $name
 * @return void
 */
public function configure($name)
{
    if (isset($this->loadedConfigurations[$name])) {
        return;
    }

    $this->loadedConfigurations[$name] = true;

    $path = $this->getConfigurationPath($name);

    if ($path) {
        $this->make('config')->set($name, require $path);
    }
}

How to override those values or make it to avoid those conditions: isset($this->loadedConfigurations[$name]) ?



via wujt

Advertisement