public function generate($env, $example, array $app = [])
    {
        $result = false;

        $envValues = $this->getValuesFromFile($env, false);
        $exampleValues = $this->getValuesFromFile($example);
        $allValues = array_merge($exampleValues, $envValues, $app);

        $content = '';
        foreach ($allValues as $key => $value) {
            $content .= $key . '=' . $value . "\n";
        }

        if (file_put_contents($env, $content)) {
            $result = true;
        }

        return $result;
    }
public function generate($env, $example, array $app = [])
    {
        $result = false;

        $envValues = $this->getValuesFromFile($env, false);
        $exampleValues = $this->getValuesFromFile($example);
        $allValues = array_merge($exampleValues, $envValues, $app);

        $content = '';
        foreach ($allValues as $key => $value) {
            $content .= $key . '=' . $value . "\n";
        }

        if (file_put_contents($env, $content)) {
            $result = true;
        }

        return $result;
    }
public function generate ( $ env , $ example , array $ app = [ ] ) { $ result = false ; $ envValues = $ this -> getValuesFromFile ( $ env , false ) ; $ exampleValues = $ this -> getValuesFromFile ( $ example ) ; $ allValues = array_merge ( $ exampleValues , $ envValues , $ app ) ; $ content = '' ; foreach ( $ allValues as $ key => $ value ) { $ content .= $ key . '=' . $ value . "\n" ; } if ( file_put_contents ( $ env , $ content ) ) { $ result = true ; } return $ result ; }
Generate a .env file

Start with system defaults. Overwrite with `.env.example`
values. Overwrite with values from `.env` if exists.
Overwrite with values from $app (command line), if given.
Save the result in `.env`.

@param string $env Path to .env file
@param string $example Path to .env.example file
@param array $app Array of command line arguments
@return bool True on success, false or exception otherwise
Generate a . env file