When deploying to a server where we cache the config, we cannot use the environment variables directly.
So we want to use the array of credentials in the config file firebase.php
The only way I can see to do this at the moment is to replace the FirebaseProjectManager with my own that extends it and adds the following to the configure method before the final $factory->withHttpClientOptions call:
if ($projectId = $config['credentials']['project_id'] ?? null) {
$factory = $factory->withProjectId($projectId)->withServiceAccount($config['credentials']);
return new FirebaseProject($factory, $config);
}
composer 2.7.7 Composer package
composer-plugin-api 2.6.0 The Composer Plugin API
composer-runtime-api 2.2.2 The Composer Runtime API
ext-ctype 8.3.8 The ctype PHP extension
ext-curl 8.3.8 The curl PHP extension
ext-date 8.3.8 The date PHP extension
ext-dom 20031129 The dom PHP extension
ext-exif 8.3.8 The exif PHP extension
ext-fileinfo 8.3.8 The fileinfo PHP extension
ext-filter 8.3.8 The filter PHP extension
ext-gd 8.3.8 The gd PHP extension
ext-hash 8.3.8 The hash PHP extension
ext-iconv 8.3.8 The iconv PHP extension
ext-imagick 3.7.0 The imagick PHP extension
ext-intl 8.3.8 The intl PHP extension
ext-json 8.3.8 The json PHP extension
ext-libxml 8.3.8 The libxml PHP extension
ext-mbstring 8.3.8 The mbstring PHP extension
ext-mysqli 8.3.8 The mysqli PHP extension
ext-mysqlnd 0 The mysqlnd PHP extension (actual version: mysqlnd 8.3.8)
ext-openssl 8.3.8 The openssl PHP extension
ext-pcntl 8.3.8 The pcntl PHP extension
ext-pcre 8.3.8 The pcre PHP extension
ext-pdo 8.3.8 The PDO PHP extension
ext-pdo_mysql 8.3.8 The pdo_mysql PHP extension
ext-pdo_sqlite 8.3.8 The pdo_sqlite PHP extension
ext-phar 8.3.8 The Phar PHP extension
ext-posix 8.3.8 The posix PHP extension
ext-random 8.3.8 The random PHP extension
ext-readline 8.3.8 The readline PHP extension
ext-redis 6.0.2 The redis PHP extension
ext-reflection 8.3.8 The Reflection PHP extension
ext-session 8.3.8 The session PHP extension
ext-simplexml 8.3.8 The SimpleXML PHP extension
ext-soap 8.3.8 The soap PHP extension
ext-sockets 8.3.8 The sockets PHP extension
ext-sodium 8.3.8 The sodium PHP extension
ext-spl 8.3.8 The SPL PHP extension
ext-sqlite3 8.3.8 The sqlite3 PHP extension
ext-tokenizer 8.3.8 The tokenizer PHP extension
ext-xml 8.3.8 The xml PHP extension
ext-xmlreader 8.3.8 The xmlreader PHP extension
ext-xmlwriter 8.3.8 The xmlwriter PHP extension
ext-yaml 2.2.3 The yaml PHP extension
ext-zend-opcache 8.3.8 The Zend OPcache PHP extension
ext-zip 1.22.3 The zip PHP extension
ext-zlib 8.3.8 The zlib PHP extension
lib-curl 7.88.1 The curl library
lib-curl-libssh2 1.10.0 curl libssh2 version
lib-curl-openssl 3.0.11 curl OpenSSL version (3.0.11)
lib-curl-zlib 1.2.13 curl zlib version
lib-date-timelib 2022.10 date timelib version
lib-date-zoneinfo 2024.1 zoneinfo ("Olson") database for date
lib-fileinfo-libmagic 543 fileinfo libmagic version
lib-gd 2.0.35 The gd library
lib-gd-freetype 2.12.1 freetype version for gd
lib-gd-libjpeg 6.2 libjpeg version for gd
lib-gd-libpng 1.6.39 libpng version for gd
lib-gd-libxpm 3.4.11 libxpm version for gd
lib-iconv 2.36 The iconv library
lib-icu 72.1 The ICU unicode and globalization support library
lib-icu-cldr 42 ICU CLDR project version
lib-icu-unicode 15.0.0 ICU unicode version
lib-icu-zoneinfo 2022.5 zoneinfo ("Olson") database for icu
lib-imagick-imagemagick 6.9.11.60 The imagick-imagemagick library
lib-libsodium 1.0.18 The libsodium library
lib-libxml 2.9.14 libxml library version
lib-mbstring-libmbfl 1.3.2 mbstring libmbfl version
lib-mbstring-oniguruma 6.9.8 mbstring oniguruma version
lib-openssl 3.0.11 OpenSSL 3.0.11 19 Sep 2023
lib-pcre 10.42 The pcre library
lib-pcre-unicode 14.0.0 PCRE Unicode version support
lib-pdo_sqlite-sqlite 3.40.1 The pdo_sqlite-sqlite library
lib-sqlite3-sqlite 3.40.1 The sqlite3-sqlite library
lib-yaml-libyaml 0.2.5 libyaml version of yaml
lib-zip-libzip 1.7.3 The zip-libzip library
lib-zlib 1.2.13 The zlib library
php 8.3 Package overridden via config.platform, actual: 8.3.8
php-64bit 8.3 Package overridden via config.platform, actual: 8.3.8
php-ipv6 8.3 Package overridden via config.platform, actual: 8.3.8
Steps to reproduce the issue.
# Insert the commands issued in the terminal if they are needed
# to reproduce the issue. Otherwise, delete this code block.
// Insert the PHP code to reproduce the issue. Please ensure that it is code that
// can be copy pasted to reproduce it.
Error message/Stack trace
[#638 New error: Kreait\Firebase\Exception\RuntimeException: Unable to determine the Firebase Project ID]
Additional information
I couldn't see in the docs how to use the credentials array, other than it says they are supported so I think this is an oversight rather than intentional, the code provided should resolve the issue.
Describe the bug
When deploying to a server where we cache the config, we cannot use the environment variables directly.
So we want to use the array of credentials in the config file
firebase.php
The only way I can see to do this at the moment is to replace the
FirebaseProjectManager
with my own that extends it and adds the following to theconfigure
method before the final$factory->withHttpClientOptions
call:Installed packages
PHP version and extensions
Steps to reproduce the issue.
Error message/Stack trace
Additional information
I couldn't see in the docs how to use the credentials array, other than it says they are supported so I think this is an oversight rather than intentional, the code provided should resolve the issue.