feat: add support for .env with comments
This commit is contained in:
@@ -10,6 +10,9 @@ class DotEnv {
|
|||||||
$contents = file_get_contents($filepath);
|
$contents = file_get_contents($filepath);
|
||||||
$lines = explode(PHP_EOL, $contents);
|
$lines = explode(PHP_EOL, $contents);
|
||||||
$envvars = array_reduce($lines, function ($vars, $line) {
|
$envvars = array_reduce($lines, function ($vars, $line) {
|
||||||
|
if (strpos(ltrim($line), '#') === 0) {
|
||||||
|
return $vars;
|
||||||
|
}
|
||||||
$parts = explode('=', $line);
|
$parts = explode('=', $line);
|
||||||
$partsCount = count($parts);
|
$partsCount = count($parts);
|
||||||
if ($partsCount === 1 && strlen($parts[0]) <= 0) {
|
if ($partsCount === 1 && strlen($parts[0]) <= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user