dotenv-org / phpdotenv-vault Goto Github PK
View Code? Open in Web Editor NEWLoad environment variables from encrypted .env.vault files
Home Page: https://www.dotenv.org/docs/languages/php
License: BSD 3-Clause "New" or "Revised" License
Load environment variables from encrypted .env.vault files
Home Page: https://www.dotenv.org/docs/languages/php
License: BSD 3-Clause "New" or "Revised" License
Hi,
it is not possible to call phpdotenv methods like:
$dotenv = DotenvVault::createImmutable(__DIR__, '.env.vault');
$dotenv->load();
$dotenv->required('DATABASE_DSN');
Throws:
Repository is not set
Solution:
phpdotenv-vault/src/DotenvVault.php
Lines 24 to 35 in 61dbb12
public function __construct(
StoreInterface $store,
ParserInterface $parser,
LoaderInterface $loader,
RepositoryInterface $repository
)
{
$this->store = $store;
$this->parser = $parser;
$this->loader = $loader;
$this->repository = $repository;
parent::__construct($store, $parser, $loader, $repository);
}
Hi,
if there is no DOTENV_KEY phpdotenv-vault fallback to the unencrypted .env file.
In this case there is a var_dump
on first .env entry (ref)
var_dump($entries[0]->getName());
var_dump($entries[0]->getValue());
If there should be an output, it would be better to add a notice or warning so that it can be ignored by error_reporting
.
trigger_error('Fallback to unencrypted .env', E_USER_NOTICE);
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:
$dotenv = DotenvVault::createImmutable(__DIR__, '.env.vault');
$dotenv->load();
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
.
How to deal with it?
Hi,
the class name is written in CamelCase so the current readme example:
Lines 37 to 41 in 61dbb12
Should be look like:
use DotenvVault\DotEnvVault;
require 'vendor/autoload.php';
$dotenv = DotEnvVault::createImmutable(__DIR__, '.env.vault');
$dotenv->load(); # take environment variables from .env.vault
Writing a library for PHP but requiring Node.Js (The NPX)? Why not using PHP's in built system?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.