1. Go to this page and download the library: Download tatter/firebase 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/ */
// Get the component
$caller = service('firebase')->caller;
// Set the UID of the user making the call
$caller->setUid($user->uid);
// Make the call
$data = ['customerId' => 7, 'charge' => 3.50];
$response = $caller->call('https://us-central1-myproject.cloudfunctions.net/addCharge', $data);
if ($response === null) {
echo implode(' ', $caller->getErrors());
}
else {
print_r($response);
}
helper('firestore');
$document = firestore()->collection('users')->document('lovelace');
$document->set([
'first' => 'Ada',
'last' => 'Lovelace',
'born' => 1815
]);
printf('Added data to the "lovelace" document in the users collection.');
namespace App\Collections;
use App\Entities\Widget;
use Tatter\Firebase\Firestore\Collection;
final class WidgetCollection extends Collection
{
public const NAME = 'widgets';
public const ENTITY = Widget::class;
}