Created
February 20, 2023 06:00
-
-
Save rjocoleman/ba167491f4723ebbc60d376b15007e5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b4ddd1a6d0faf0162f00f3dd80516e62c434523e Mon Sep 17 00:00:00 2001 | |
From: Robert Coleman <github@robert.net.nz> | |
Date: Sun, 4 Dec 2022 22:05:59 +1300 | |
Subject: [PATCH] support db config via database url | |
--- | |
src/DbDumperFactory.php | 5 +++++ | |
tests/DbDumperFactoryTest.php | 19 +++++++++++++++++++ | |
2 files changed, 24 insertions(+) | |
diff --git a/src/DbDumperFactory.php b/src/DbDumperFactory.php | |
index 0592e30..06596c8 100644 | |
--- a/src/DbDumperFactory.php | |
+++ b/src/DbDumperFactory.php | |
@@ -4,6 +4,7 @@ | |
use Illuminate\Support\Arr; | |
use Illuminate\Support\Str; | |
+use Illuminate\Support\ConfigurationUrlParser; | |
use Spatie\DbDumper\Databases\MySql; | |
use Spatie\DbDumper\Databases\PostgreSql; | |
use Spatie\DbDumper\Databases\Sqlite; | |
@@ -20,6 +21,10 @@ public static function createForConnection(string $connectionName): DbDumper | |
throw CannotCreateDbDumper::connectionDoesNotExist($connectionName); | |
} | |
+ if (! empty($dbConfig['url'])) { | |
+ $dbConfig = (new ConfigurationUrlParser)->parseConfiguration($dbConfig); | |
+ } | |
+ | |
$fallback = Arr::get( | |
$dbConfig, | |
'read.host', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment