public function getValuesFromFile($file, $failOnMissing = true)
    {
        $result = [];

        if (!FileSystem::isFileReadable($file)) {
            if ($failOnMissing) {
                throw new RuntimeException("Path [$file] is not a readable file");
            }
            return $result;
        }

        $file = file($file);
        if (empty($file)) {
            return $result;
        }

        foreach ($file as $line) {
            $line = trim($line);
            if (!preg_match('#^(.*)?=(.*)?$#', $line, $matches)) {
                continue;
            }
            $result[$matches[1]] = $matches[2];
        }

        return $result;
    }
public function getValuesFromFile($file, $failOnMissing = true)
    {
        $result = [];

        if (!FileSystem::isFileReadable($file)) {
            if ($failOnMissing) {
                throw new RuntimeException("Path [$file] is not a readable file");
            }
            return $result;
        }

        $file = file($file);
        if (empty($file)) {
            return $result;
        }

        foreach ($file as $line) {
            $line = trim($line);
            if (!preg_match('#^(.*)?=(.*)?$#', $line, $matches)) {
                continue;
            }
            $result[$matches[1]] = $matches[2];
        }

        return $result;
    }
public function getValuesFromFile ( $ file , $ failOnMissing = true ) { $ result = [ ] ; if ( ! FileSystem :: isFileReadable ( $ file ) ) { if ( $ failOnMissing ) { throw new RuntimeException ( "Path [$file] is not a readable file" ) ; } return $ result ; } $ file = file ( $ file ) ; if ( empty ( $ file ) ) { return $ result ; } foreach ( $ file as $ line ) { $ line = trim ( $ line ) ; if ( ! preg_match ( '#^(.*)?=(.*)?$#' , $ line , $ matches ) ) { continue ; } $ result [ $ matches [ 1 ] ] = $ matches [ 2 ] ; } return $ result ; }
Get .env values from a given file

@throws \RuntimeException when file is missing and $failOnMissing is true
@param string $file Path to file
@param bool $failOnMissing Whether or not fail on missing file
@return array
Get . env values from a given file