diff --git a/MagentoDotenv.php b/MagentoDotenv.php index 1dcd668..b05dc65 100644 --- a/MagentoDotenv.php +++ b/MagentoDotenv.php @@ -5,6 +5,9 @@ namespace Zepgram\Component\MagentoDotenv; use Symfony\Component\Dotenv\Dotenv as SymfonyDotenv; +use function copy; +use function is_file; +use function touch; class MagentoDotenv { @@ -32,16 +35,16 @@ class MagentoDotenv public static function init(): void { $dotenvDest = ROOT_DIRECTORY . self::DEST_APP_ETC_DOTENV_FILE; - if (\is_file($dotenvDest)) { + if (is_file($dotenvDest)) { require_once $dotenvDest; return; } else { $dotenvSrc = ROOT_DIRECTORY . self::SRC_APP_ETC_DOTENV_FILE; - \copy($dotenvSrc, $dotenvDest); + copy($dotenvSrc, $dotenvDest); } $magentoBootstrapFile = ROOT_DIRECTORY . self::MAGENTO_BOOTSTRAP_FILE; - if (!\is_file($magentoBootstrapFile)) { + if (!is_file($magentoBootstrapFile)) { return; } @@ -64,6 +67,10 @@ public static function get( if ($envFilePath !== '') { $envFilePath = $envFilePath . DIRECTORY_SEPARATOR; } + $envFile = ROOT_DIRECTORY . $envFilePath . self::ENV_FILE; + if (!is_file($envFile)) { + touch($envFile); + } $dotenv = new SymfonyDotenv($envKey, $debugKey); $dotenv->usePutEnv($usePutEnv); diff --git a/composer.json b/composer.json index 7673aa5..8b15c0e 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Simple autoloader to integrate the Symfony Dotenv component into Magento2", "keywords": ["magento2", "environment", "env", "dotenv"], "type": "magento2-component", - "version": "2.0.1", + "version": "2.0.2", "authors":[ { "name": "Benjamin Calef",