PHP code example of elfadl / yii2-firebase-helper

1. Go to this page and download the library: Download elfadl/yii2-firebase-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elfadl / yii2-firebase-helper example snippets


...
'components' => [
    'firebase' => [
        'class'=>'elfadl\Firebase\Firebase',
        'credential_file'=>'service_account.json', // (see https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app)
        'database_uri'=>'https://my-project.firebaseio.com', // (optional)
    ]
...
]


//and 
(new yii\web\Application($config))->run();


//and
(new \elfadl\Firebase\web\Application($config))->run();


$database = Yii::$app->firebase->getDatabase();
$reference = $database->getReference('path/to/child/location');
$value = $reference->getValue();

$reference = Yii::$app->firebase->getReference('path/to/child/location');
$value = $reference->getValue();