Skip to content

Commit

Permalink
added .env support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijzer committed Sep 21, 2023
1 parent df8816f commit 190f809
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CACHE_PATH=/app/var/cache
18 changes: 18 additions & 0 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
use Misery\Component\Converter\AkeneoCsvHeaderContext;
use Misery\Component\Converter\AkeneoCsvToStructuredDataConverter;

// Path to your .env file (assuming it's in the project root)
$envFilePath = __DIR__ . '/../.env';

if (file_exists($envFilePath)) {
$lines = file($envFilePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

foreach ($lines as $line) {
// Skip comments and lines that don't contain an equals sign
if (str_starts_with(trim($line), '#') === 0 || strpos($line, '=') === false) {
continue;
}

list($key, $value) = explode('=', $line, 2);
$_ENV[trim($key)] = trim($value);
$_SERVER[trim($key)] = trim($value);
}
}

$sourceRegistry = new Misery\Component\Common\Registry\Registry('source_command');
$sourceRegistry->registerAllByName(
new Misery\Component\Source\Command\SourceFilterCommand(),
Expand Down

0 comments on commit 190f809

Please sign in to comment.