Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active September 22, 2017 23:12
Show Gist options
  • Save vielhuber/73931efe0aa78dd59ef9 to your computer and use it in GitHub Desktop.
Save vielhuber/73931efe0aa78dd59ef9 to your computer and use it in GitHub Desktop.
get env variables from outside #laravel
<?php
$_ENV = array();
$handle = fopen(".env", "r");
if($handle) {
while (($line = fgets($handle)) !== false) {
if( strpos($line,"=") !== false) {
$var = explode("=",$line);
$_ENV[$var[0]] = trim($var[1]);
}
}
fclose($handle);
} else { die('error opening .env'); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment