Created
February 15, 2022 14:02
-
-
Save saranshdhingra/5e53365371d265fd28fc9b15534289b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"require": { | |
"google/cloud-firestore": "^1.21" | |
} | |
} |
This file contains hidden or 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 ubuntu:18.04 | |
WORKDIR /var/www | |
RUN apt-get update | |
ARG DEBIAN_FRONTEND=noninteractive | |
ENV TZ=Etc/UTC | |
RUN apt-get install -y php7.2-dev php-pear libz-dev curl zip | |
RUN pecl install grpc | |
RUN echo "extension=grpc.so" > /etc/php/7.2/cli/conf.d/grpc.ini | |
COPY . . | |
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
RUN composer update | |
# comment this if you intend to supply credentials directly in the PHP file | |
ENV GOOGLE_APPLICATION_CREDENTIALS=/var/www/key.json | |
CMD ["tail","-f"] |
This file contains hidden or 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
{ | |
"0":"overwrite this file with your service account key contents" | |
} |
This file contains hidden or 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
<?php | |
require 'vendor/autoload.php'; | |
use Google\Cloud\Firestore\FirestoreClient; | |
// the projectId will either be fetched from the GOOGLE_APPLICATION_CREDENTIALS env supplied in Dockerfile | |
// or you can specify here and comment it in the Dockerfile | |
$db = new FirestoreClient(); | |
// change the collectionName here | |
$usersRef = $db->collection('issue-3847'); | |
$snapshot = $usersRef->documents(); | |
foreach ($snapshot as $user) { | |
printf('User: %s' . PHP_EOL, $user->id()); | |
printf(PHP_EOL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment