after updating to package version 0.1.2, phpdotenv-vault throws:
NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment DOTENV_VAULT_DEVELOPMENT in your .env.vault file. Run 'npx dotenv-vault build' to include it.
The function createImmutable calls RepositoryBuilder::createWithDefaultAdapters(). The used default adapters are ServerConstAdapter and EnvConstAdapter (ref vlucas/phpdotenv/src/Repository/RepositoryBuilder.php).
These adapters write our environment variables to $_SERVER and $_ENV. So with these adapers we can't access our variables via getenv. The needed PutenvAdapter is only added inside createUnsafeImmutable.
Hi,
after updating to package version 0.1.2, phpdotenv-vault throws:
NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment DOTENV_VAULT_DEVELOPMENT in your .env.vault file. Run 'npx dotenv-vault build' to include it.
PHP: 8.2 phpdotenv-vault: 0.1.2
In my opinion the problem is, the last change Use getenv instead of
Why? We load our .env with the following code:
The function
createImmutable
callsRepositoryBuilder::createWithDefaultAdapters()
. The used default adapters areServerConstAdapter
andEnvConstAdapter
(ref vlucas/phpdotenv/src/Repository/RepositoryBuilder.php). These adapters write our environment variables to$_SERVER
and$_ENV
. So with these adapers we can't access our variables viagetenv
. The neededPutenvAdapter
is only added insidecreateUnsafeImmutable
.How to deal with it?