kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
992 stars 163 forks source link

Fetch all firebase auth user #143

Closed jatinbphp closed 1 year ago

jatinbphp commented 1 year ago

Hello,

I want to get all firebase auth users.

I have installed package and followed all instruction like below FIREBASE_CREDENTIALS=/var/www/html/project/firebase.json

than in my controller use Kreait\Laravel\Firebase\Facades\Firebase;

In my method: $appAuth = Firebase::project('app')->auth();

    $users = $appAuth->listUsers($defaultMaxResults = 1000, $defaultBatchSize = 1000);

    print_r($users);
    exit;

I am getting "Generator Object ( )" as output. Not sure if I am doing anything wrong or not. Please guide.

jeromegamez commented 1 year ago

Hey there 👋,

the method indeed returns a Generator (https://firebase-php.readthedocs.io/en/stable/user-management.html#list-users) that you can either iterate through, for example, with foreach() or convert it to an array with iterator_to_array() in order to be able to use print_r().

With projects having hundreds of thousands of users (including anonymous users) a Generator is the most efficient way to get them.

jatinbphp commented 1 year ago

Thank you very much. It works as you mentioned.!!!!