diff --git a/src/Sentry/Laravel/Console/PublishCommand.php b/src/Sentry/Laravel/Console/PublishCommand.php index db7fab11..d51a8e75 100644 --- a/src/Sentry/Laravel/Console/PublishCommand.php +++ b/src/Sentry/Laravel/Console/PublishCommand.php @@ -107,7 +107,7 @@ private function setEnvValues(array $values): bool if (count($values) > 0) { foreach ($values as $envKey => $envValue) { if ($this->isEnvKeySet($envKey, $envFileContents)) { - $envFileContents = preg_replace("/^{$envKey}=.*?[\s$]/m", "{$envKey}={$envValue}\n", $envFileContents); + $envFileContents = preg_replace("/^{$envKey}=\"?.*?\"?(\s|$)/m", "{$envKey}={$envValue}\n", $envFileContents); $this->info("Updated {$envKey} with new value in your `.env` file."); } else { @@ -131,7 +131,7 @@ private function isEnvKeySet(string $envKey, ?string $envFileContents = null): b { $envFileContents = $envFileContents ?? file_get_contents(app()->environmentFilePath()); - return (bool)preg_match("/^{$envKey}=.*?[\s$]/m", $envFileContents); + return (bool)preg_match("/^{$envKey}=\"?.*?\"?(\s|$)/m", $envFileContents); } private function askForDsnInput(): string