Category : environment-variables

In my konfiguration.php I have the following code $line = trim($line); if (!empty($line)) { putenv($line); [$key, $value] = explode(‘=’, $line); $_ENV[$key] = $value ?? ”; } } In my .env file I have the following line DATABASE_PASSWOR**D**=anyStringOfUpperAndLowerCaseLettersAndNumbersOnly In my application_head.php I have the following code to open the database: try { $db = new PDO(‘mysql:host=’ ..

Read more

If a PHP package I’m developing must use environment variables, how should I load them? According to the docs: $dotEnv = Dotenv::createImmutable(__DIR__ . ‘/../’); // or Dotenv::createImmutable(getcwd()) $dotEnv->load(); But I’m loading the package’s own .env which of course doesn’t make any sense. How is the flow? I’ve been looking for documentation about this in Dotenv ..

Read more