From 8fd034e4ea0ea726d20376c4371c1e1a7dad4c46 Mon Sep 17 00:00:00 2001 From: Tony Coyle Date: Mon, 22 Apr 2024 16:24:16 +1200 Subject: [PATCH 1/3] Add environment variable flag to silence error_log on init. --- README.md | 4 ++++ src/DotenvVault.php | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99ef313..469ad4b 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ Yes. It is safe and recommended to do so. It contains your encrypted envs, and y No. It is the key that unlocks your encrypted environment variables. Be very careful who you share this key with. Do not let it leak. +#### Can I silence the logging? + +Yes. Set `DOTENV_VAULT_SILENT=true` in your environment. + ## Contributing 1. Fork it diff --git a/src/DotenvVault.php b/src/DotenvVault.php index 1ab8436..1ccf48d 100644 --- a/src/DotenvVault.php +++ b/src/DotenvVault.php @@ -180,7 +180,11 @@ public function load() public function _log($message) { - error_log("[dotenv-vault][INFO] {$message}"); + if (getenv('DOTENV_VAULT_SILENT') === 'true') { + return; + } + + error_log("[dotenv-vault][INFO] {$message}", 4); } public function _loadDotenv() @@ -236,7 +240,7 @@ public function _decryptVault() // Decrypt $decrypted = (new Decrypter())->decrypt($attrs['ciphertext'], $attrs['key']); - + // If successful, break the loop break; } catch (Exception $error) { From e6da3f9581790aba51122f1c7f2bd651e6377cb1 Mon Sep 17 00:00:00 2001 From: Tony Coyle Date: Thu, 30 Jan 2025 12:42:53 +1300 Subject: [PATCH 2/3] Removed environment flag and reverting to commenting out log until proper logging handling in place from upstream repository. --- README.md | 4 ---- src/DotenvVault.php | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 469ad4b..99ef313 100644 --- a/README.md +++ b/README.md @@ -139,10 +139,6 @@ Yes. It is safe and recommended to do so. It contains your encrypted envs, and y No. It is the key that unlocks your encrypted environment variables. Be very careful who you share this key with. Do not let it leak. -#### Can I silence the logging? - -Yes. Set `DOTENV_VAULT_SILENT=true` in your environment. - ## Contributing 1. Fork it diff --git a/src/DotenvVault.php b/src/DotenvVault.php index 1ccf48d..7740e1a 100644 --- a/src/DotenvVault.php +++ b/src/DotenvVault.php @@ -180,11 +180,7 @@ public function load() public function _log($message) { - if (getenv('DOTENV_VAULT_SILENT') === 'true') { - return; - } - - error_log("[dotenv-vault][INFO] {$message}", 4); +// error_log("[dotenv-vault][INFO] {$message}", 4); } public function _loadDotenv() From dc97633892e6120a18cf3c8000bf965197956a70 Mon Sep 17 00:00:00 2001 From: Tony Coyle Date: Wed, 7 Jan 2026 10:20:11 +1300 Subject: [PATCH 3/3] Implicitly marking parameter $fileEncoding as nullable is deprecated in PHP 8.4 adjusting to maintain backward compatibility and remove deprecation errors. --- src/DotenvVault.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DotenvVault.php b/src/DotenvVault.php index 7740e1a..172b8cd 100644 --- a/src/DotenvVault.php +++ b/src/DotenvVault.php @@ -62,7 +62,7 @@ public function __construct( * * @return \Dotenv\Dotenv */ - public static function create(RepositoryInterface $repository, $paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function create(RepositoryInterface $repository, $paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $builder = $names === null ? StoreBuilder::createWithDefaultName() : StoreBuilder::createWithNoNames(); @@ -91,7 +91,7 @@ public static function create(RepositoryInterface $repository, $paths, $names = * * @return \DotenvVault\DotenvVault */ - public static function createMutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createMutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters()->make(); @@ -108,7 +108,7 @@ public static function createMutable($paths, $names = null, bool $shortCircuit = * * @return \DotenvVault\DotenvVault */ - public static function createUnsafeMutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createUnsafeMutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters() ->addAdapter(PutenvAdapter::class) @@ -127,7 +127,7 @@ public static function createUnsafeMutable($paths, $names = null, bool $shortCir * * @return \DotenvVault\DotenvVault */ - public static function createImmutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createImmutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters()->immutable()->make(); @@ -144,7 +144,7 @@ public static function createImmutable($paths, $names = null, bool $shortCircuit * * @return \DotenvVault\DotenvVault */ - public static function createUnsafeImmutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + public static function createUnsafeImmutable($paths, $names = null, bool $shortCircuit = true, ?string $fileEncoding = null) { $repository = RepositoryBuilder::createWithDefaultAdapters() ->addAdapter(PutenvAdapter::class)