|
|
@ -4,23 +4,21 @@ namespace jrosset\EnvReader;
|
|
|
|
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
|
|
|
|
class EnvConfig extends GenericConfig {
|
|
|
|
abstract class EnvConfig extends GenericConfig {
|
|
|
|
/**
|
|
|
|
use TExternalFile;
|
|
|
|
* ENV file path
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected const PATH_ENV = '.env';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function readConfig (): void {
|
|
|
|
protected function readConfig (): void {
|
|
|
|
if (!file_exists(static::PATH_ENV)) {
|
|
|
|
$configFile = $this->getConfigFilePath();
|
|
|
|
|
|
|
|
if (!file_exists($configFile)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$lines = file(static::PATH_ENV, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
|
|
$lines = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
|
|
if ($lines === false) {
|
|
|
|
if ($lines === false) {
|
|
|
|
throw new Exception('Unable to read environment file "' . static::PATH_ENV . '"');
|
|
|
|
throw new Exception('Unable to read environment file "' . $configFile . '"');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($lines as $line) {
|
|
|
|
foreach ($lines as $line) {
|
|
|
|