From 77420c68ed8561056204a2214aae58468cca962b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcholas=20Andr=C3=A9?= Date: Tue, 24 Nov 2020 23:10:31 -0300 Subject: [PATCH] Adding support for FIRESTORE_EMULATOR_HOST env variable --- src/FirestoreClient.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/FirestoreClient.php b/src/FirestoreClient.php index fdc5fc1..b7aa24f 100644 --- a/src/FirestoreClient.php +++ b/src/FirestoreClient.php @@ -176,10 +176,15 @@ public static function getRelativeDatabasePath() return 'projects/' . self::getConfig('projectId') . '/databases/' . self::getConfig('database'); } - public function getApiEndPoint() - { - return $this->apiRoot; - } + public function getApiEndPoint() { + $emulator = getenv('FIRESTORE_EMULATOR_HOST'); + + if ($emulator) { + return $emulator; + } + + return $this->apiRoot; + } /** * @param bool $status