PHPackages                             grandmasterxxx/yii2-firestore - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. grandmasterxxx/yii2-firestore

ActiveLibrary

grandmasterxxx/yii2-firestore
=============================

A Yii2 Component that connects to Google Firestore

v1.0.0(6y ago)010MITPHP

Since Jul 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/GrandMasterXXX/yii2-firestore)[ Packagist](https://packagist.org/packages/grandmasterxxx/yii2-firestore)[ RSS](/packages/grandmasterxxx-yii2-firestore/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

yii2-firestore
==============

[](#yii2-firestore)

A Yii2 Component that connects to Google Firestore

Before using this plugin, run this command on your server:

```
    pecl install protobuf
```

To install with composer, add this to your composer.json file:

```
    {
        "require": {
            "grandmasterxxx/yii2-firestore":"master",
        },
        "repositories": [
            {
                "type": "vcs",
                "url": "https://github.com/grandmasterxxx/yii2-firestore.git"
            }
        ]
    }
```

In your main-local:

```
        'firestore' => [
            'class' => 'vendor\grandmasterxxx\yii2firestore\FirestoreComponent',
            'credential_file'=>'/path/to/your/firebase_auth.json',
            'project' => 'your-project-name',
        ],
```

Code Examples:

```
    /**
     * Firestore Add
     */
    public function actionUnitFirestoreAdd()
    {
        $person = array(
            "name" => "Jhon Doe"
        );

        print_r(Yii::$app->firestore->add('people', $person)); // this generates an $id for other functions
    }

    /**
     * Firestore Get
     * @param String $id
     */
    public function actionUnitFirestoreGet($id)
    {
        print_r(Yii::$app->firestore->get('people', $id));
    }

    /**
     * Firestore Update
     * @param String $id
     */
    public function actionUnitFirestoreUpdate($id)
    {
        $arr = array(
            "name" => "Jhon Doe",
            "nested-data" => array(
                "age" => "30",
                "hair-color" => "brown",
                "eye-color" => "green",
                "height" => "5ft, 2in"
            )
        );
        print_r(Yii::$app->firestore->update('people', $id, $arr));
    }

    /**
     * Unit Test for Firestore Remove
     * @param String $id
     */
    public function actionUnitFirestoreRemove($id)
    {
        print_r(Yii::$app->firestore->remove('people', $id)); // this actually doesn't work yet
    }

    /**
     * Queries Firestore
     */
    public function actionQueryFirestore()
    {
        $conditions = array(

                array(
                    "property" => "timestamp",
                    "operator" => ">=",
                    "comparison" => Yii::$app->firestore->timestamp(new \DateTime("Mon Aug 19st 2019"))
                    ),

                array(
                    "property" => "timestamp",
                    "operator" => "
